From 94717c131570c66fffdd2354ff4f050c12970e34 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Fri, 31 Jul 2026 20:57:42 -0700 Subject: [PATCH 1/2] [RN] Make yarn the source of truth for JS lint/format ## Summary Point synced JavaScript formatting and linting at the repository's own Prettier + ESLint so CI is the source of truth: add `yarn f` (Prettier), expand the Prettier globs to all JS-family extensions, and make the CI ESLint step propagate its exit status instead of swallowing it. ## Changelog [Internal] ## Test Plan `yarn lint`, `yarn format-check`, and `yarn f` run from the repo root; the GitHub `lint` job runs both on this PR. Changelog: [Internal] --- .github/workflows/test-all.yml | 2 +- package.json | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index 3b1a45e6bd3..0d2262dc5d5 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -507,7 +507,7 @@ jobs: run: yarn run lint-markdown - name: ESLint shell: bash - run: ./.github/workflow-scripts/exec_swallow_error.sh yarn lint --format junit -o ./reports/junit/eslint/results.xml + run: yarn lint - name: Flow shell: bash run: yarn flow-check diff --git a/package.json b/package.json index e5ff3fa3773..a4c82b94bba 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,9 @@ "cxx-api-validate": "python -m scripts.cxx-api.parser --validate", "flow-check": "flow full-check", "flow": "flow", - "format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"", - "format": "npm run prettier && npm run clang-format", + "f": "yarn prettier", + "format-check": "prettier --list-different \"./**/*.{cjs,cts,flow,js,jsx,md,mjs,mts,ts,tsx,yaml,yml}\"", + "format": "yarn prettier && yarn clang-format", "featureflags": "yarn --cwd packages/react-native featureflags", "js-api-diff": "node ./scripts/js-api/diff-api-snapshot", "lint-kotlin-check": "./gradlew ktfmtCheck", @@ -24,7 +25,7 @@ "lint-markdown": "markdownlint-cli2 2>&1", "lint": "eslint --max-warnings 0 .", "preinstall": "node ./scripts/try-set-hermes-compiler-prebuilt.js", - "prettier": "prettier --write \"./**/*.{js,md,yml,ts,tsx}\"", + "prettier": "prettier --write \"./**/*.{cjs,cts,flow,js,jsx,md,mjs,mts,ts,tsx,yaml,yml}\"", "shellcheck": "./.github/workflow-scripts/analyze_scripts.sh", "start": "yarn --cwd packages/rn-tester start", "set-version": "node ./scripts/releases/set-version.js", From e5a91e45ccd86e23e07340f1862bf641e45cb01f Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Mon, 3 Aug 2026 17:34:31 -0700 Subject: [PATCH 2/2] [RN] Make yarn the source of truth for native (C++/Kotlin) format ## Summary Extend yarn-owned formatting to native sources so GitHub CI is the single source of truth for C/C++/Obj-C and Kotlin, using the OSS toolchain so internal (Meta) and GitHub produce byte-identical output: - Add `scripts/lint/clang-format.sh` (pins clang-format `21.1.2` from PyPI) and `scripts/lint/ktfmt.sh` (pins ktfmt `0.64` from Maven Central; requires JDK 17+, selected from `JAVA_HOME`/PATH). Both derive the file list from `git ls-files` and honor the existing vendored/generated exclusions. - Point `yarn clang-format` + new `yarn clang-format-check`, and `yarn lint-kotlin` + `yarn lint-kotlin-check`, at those scripts. `yarn f` now runs Prettier + clang-format + ktfmt. - Run `clang-format-check` and `ktfmt` (Kotlin) in the CI `lint` job (JDK 17 via `setup-java`). ktfmt was previously disabled in gradle ("handled inside fbsource"); the repo now owns it. - Reformat 78 Kotlin files that differed under ktfmt `0.64` (meta style: 2-space block indent, 4-space continuation, 100 column, keep unused imports). ## Changelog [Internal] ## Test Plan `yarn clang-format-check` -> clean; `yarn lint-kotlin-check` (JDK 17) -> clean; `yarn f` formats JS + native. The GitHub `lint` job runs both native checks on this PR. Changelog: [Internal] --- .github/workflows/test-all.yml | 11 + package.json | 11 +- .../kotlin/com/facebook/react/ReactPlugin.kt | 89 +- .../facebook/react/tasks/BundleHermesCTask.kt | 13 +- .../com/facebook/react/utils/PathUtils.kt | 22 +- .../com/facebook/react/ReactPluginTest.kt | 33 +- .../ModelAutolinkingDependenciesJsonTest.kt | 12 +- ...AutolinkingNewArchitecturesFileTaskTest.kt | 130 +-- .../tasks/GeneratePackageListTaskTest.kt | 73 +- .../utils/PrefabPreprocessingEntryTest.kt | 9 +- .../react/utils/DependencyUtilsTest.kt | 36 +- .../react/popupmenu/PopupMenuPackage.kt | 8 +- .../react/popupmenu/ReactPopupMenuManager.kt | 11 +- .../debug/tags/ReactDebugOverlayTags.kt | 11 +- .../react/ReactAndroidHWInputDeviceHelper.kt | 43 +- .../animated/InterpolationAnimatedNode.kt | 19 +- .../bridge/queue/MessageQueueThreadImpl.kt | 23 +- .../queue/ReactQueueConfigurationSpec.kt | 9 +- .../react/defaults/DefaultReactHost.kt | 34 +- .../DefaultTurboModuleManagerDelegate.kt | 11 +- .../devsupport/DebugOverlayController.kt | 9 +- .../DefaultDevLoadingViewImplementation.kt | 11 +- .../react/devsupport/DevServerHelper.kt | 18 +- .../react/devsupport/DevSupportManagerBase.kt | 17 +- .../devsupport/PerftestDevSupportManager.kt | 13 +- .../react/devsupport/RedBoxContentView.kt | 15 +- .../react/devsupport/StackTraceHelper.kt | 17 +- .../fabric/ViewTransitionSnapshotManager.kt | 13 +- .../react/fabric/mounting/MountingManager.kt | 17 +- .../mountitems/FabricNameComponentMapping.kt | 43 +- .../turbomodule/core/TurboModuleManager.kt | 11 +- .../react/jstasks/HeadlessJsTaskContext.kt | 15 +- .../react/modules/dialog/DialogModule.kt | 15 +- .../react/modules/network/NetworkingModule.kt | 53 +- .../react/modules/toast/ToastModule.kt | 15 +- .../react/runtime/CoreReactPackage.kt | 23 +- .../facebook/react/runtime/ReactHostImpl.kt | 32 +- .../facebook/react/runtime/ReactInstance.kt | 9 +- .../react/runtime/internal/bolts/Task.kt | 42 +- .../facebook/react/shell/MainReactPackage.kt | 179 ++-- .../uimanager/BackgroundStyleApplicator.kt | 85 +- .../react/uimanager/JSPointerDispatcher.kt | 37 +- .../react/uimanager/LayoutShadowNode.kt | 17 +- .../uimanager/ReactAccessibilityDelegate.kt | 17 +- .../com/facebook/react/uimanager/Spacing.kt | 29 +- .../react/uimanager/TouchTargetHelper.kt | 39 +- .../react/uimanager/TransformHelper.kt | 11 +- .../uimanager/UIManagerModuleConstants.kt | 120 +-- .../UIManagerModuleConstantsHelper.kt | 24 +- .../com/facebook/react/uimanager/ViewProps.kt | 141 +-- .../uimanager/drawable/BorderDrawable.kt | 47 +- .../drawable/InsetBoxShadowDrawable.kt | 13 +- .../react/uimanager/style/RadialGradient.kt | 13 +- .../views/drawer/ReactDrawerLayoutManager.kt | 9 +- .../react/views/image/ReactImageView.kt | 15 +- .../views/scroll/ReactNestedScrollView.kt | 40 +- .../scroll/ReactNestedScrollViewManager.kt | 39 +- .../scroll/ReactScrollViewCommandHelper.kt | 11 +- .../views/scroll/ReactScrollViewManager.kt | 22 +- .../react/views/scroll/ScrollEvent.kt | 27 +- .../react/views/text/ReactTextUpdate.kt | 15 +- .../react/views/text/TextLayoutManager.kt | 254 +++--- .../views/textinput/ReactTextInputManager.kt | 106 +-- .../views/textinput/ReactTextScrollWatcher.kt | 27 +- .../react/views/view/ReactViewManager.kt | 25 +- .../NativeAnimatedInterpolationTest.kt | 9 +- .../facebook/react/bridge/ReactTestHelper.kt | 21 +- ...abricMountingManagerInstrumentationTest.kt | 50 +- .../fabric/events/TouchEventDispatchTest.kt | 860 +++++++++--------- .../modules/model/ReactModuleInfoTest.kt | 17 +- .../modules/network/NetworkingModuleTest.kt | 20 +- .../react/runtime/ReactHostDelegateTest.kt | 13 +- .../react/uimanager/BorderRadiusStyleTest.kt | 196 ++-- .../uimanager/JSPointerDispatcherTest.kt | 11 +- .../react/uimanager/MatrixMathHelperTest.kt | 444 ++++----- .../react/uimanager/style/ColorStopTest.kt | 87 +- .../textinput/ReactTextInputPropertyTest.kt | 31 +- .../facebook/react/uiapp/RNTesterActivity.kt | 11 +- .../react/uiapp/RNTesterApplication.kt | 24 +- .../uiapp/component/MyLegacyViewManager.kt | 11 +- scripts/lint/clang-format.sh | 34 + scripts/lint/ktfmt.sh | 59 ++ 82 files changed, 2262 insertions(+), 1994 deletions(-) create mode 100755 scripts/lint/clang-format.sh create mode 100755 scripts/lint/ktfmt.sh diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index 0d2262dc5d5..da0cd922ebc 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -514,6 +514,17 @@ jobs: - name: TypeScript (legacy deep imports / manual types) shell: bash run: yarn test-typescript-legacy + - name: clang-format (C/C++/Obj-C) + shell: bash + run: yarn run clang-format-check + - name: Set up JDK 17 + uses: actions/setup-java@v5 + with: + java-version: '17' + distribution: 'zulu' + - name: ktfmt (Kotlin) + shell: bash + run: yarn run lint-kotlin-check test_js: runs-on: ubuntu-latest diff --git a/package.json b/package.json index a4c82b94bba..a4c17dbc853 100644 --- a/package.json +++ b/package.json @@ -9,19 +9,20 @@ "build-android": "./gradlew :packages:react-native:ReactAndroid:build", "build": "node ./scripts/build/build.js", "build-types": "node ./scripts/js-api/build-types", - "clang-format": "clang-format -i --glob=*/**/*.{h,cpp,m,mm}", + "clang-format": "./scripts/lint/clang-format.sh", + "clang-format-check": "./scripts/lint/clang-format.sh --check", "clean": "node ./scripts/build/clean.js", "cxx-api-build": "python -m scripts.cxx-api.parser", "cxx-api-validate": "python -m scripts.cxx-api.parser --validate", "flow-check": "flow full-check", "flow": "flow", - "f": "yarn prettier", + "f": "yarn prettier && yarn clang-format && yarn lint-kotlin", "format-check": "prettier --list-different \"./**/*.{cjs,cts,flow,js,jsx,md,mjs,mts,ts,tsx,yaml,yml}\"", - "format": "yarn prettier && yarn clang-format", + "format": "yarn prettier && yarn clang-format && yarn lint-kotlin", "featureflags": "yarn --cwd packages/react-native featureflags", "js-api-diff": "node ./scripts/js-api/diff-api-snapshot", - "lint-kotlin-check": "./gradlew ktfmtCheck", - "lint-kotlin": "./gradlew ktfmtFormat", + "lint-kotlin-check": "./scripts/lint/ktfmt.sh --check", + "lint-kotlin": "./scripts/lint/ktfmt.sh", "lint-markdown": "markdownlint-cli2 2>&1", "lint": "eslint --max-warnings 0 .", "preinstall": "node ./scripts/try-set-hermes-compiler-prebuilt.js", diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt index 0acc972feb4..4af3f14f34c 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt @@ -200,42 +200,44 @@ class ReactPlugin : Plugin { } // We create the tasks to produce schema from JS files and generate artifacts from schema. - val generateCodegenArtifactsTask = registerCodegenTasks( - project = project, - rootExtension = rootExtension, - generatedSrcDir = generatedSrcDir, - packageJsonFile = { findPackageJsonFile(project, rootExtension.root) }, - schemaTaskName = "generateCodegenSchemaFromJavaScript", - artifactsTaskName = "generateCodegenArtifactsFromSchema", - configureJsRoot = { task, packageJson -> - // We're reading the package.json at configuration time to properly feed - // the `jsRootDir` @Input property of this task & the onlyIf. Therefore, the - // parsePackageJson should be invoked inside this lambda. - val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) } - val jsSrcsDirInPackageJson = parsedPackageJson?.codegenConfig?.jsSrcsDir - - if (packageJson != null && jsSrcsDirInPackageJson != null) { - task.jsRootDir.set(File(packageJson.parentFile, jsSrcsDirInPackageJson)) - } else { - task.jsRootDir.set(localExtension.jsRootDir) - } - }, - configureCodegenArtifacts = { task, _ -> - task.codegenJavaPackageName.set(localExtension.codegenJavaPackageName) - task.libraryName.set(localExtension.libraryName) - }, - onlyIf = { packageJson -> - // Please note that needsCodegenFromPackageJson is triggering a read of the - // package.json at configuration time as we need to feed the onlyIf condition of this - // task. Therefore, needsCodegenFromPackageJson needs to be invoked inside this - // lambda. - val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(rootExtension.root) - val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) } - val includesGeneratedCode = - parsedPackageJson?.codegenConfig?.includesGeneratedCode ?: false - (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode - }, - ) + val generateCodegenArtifactsTask = + registerCodegenTasks( + project = project, + rootExtension = rootExtension, + generatedSrcDir = generatedSrcDir, + packageJsonFile = { findPackageJsonFile(project, rootExtension.root) }, + schemaTaskName = "generateCodegenSchemaFromJavaScript", + artifactsTaskName = "generateCodegenArtifactsFromSchema", + configureJsRoot = { task, packageJson -> + // We're reading the package.json at configuration time to properly feed + // the `jsRootDir` @Input property of this task & the onlyIf. Therefore, the + // parsePackageJson should be invoked inside this lambda. + val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) } + val jsSrcsDirInPackageJson = parsedPackageJson?.codegenConfig?.jsSrcsDir + + if (packageJson != null && jsSrcsDirInPackageJson != null) { + task.jsRootDir.set(File(packageJson.parentFile, jsSrcsDirInPackageJson)) + } else { + task.jsRootDir.set(localExtension.jsRootDir) + } + }, + configureCodegenArtifacts = { task, _ -> + task.codegenJavaPackageName.set(localExtension.codegenJavaPackageName) + task.libraryName.set(localExtension.libraryName) + }, + onlyIf = { packageJson -> + // Please note that needsCodegenFromPackageJson is triggering a read of the + // package.json at configuration time as we need to feed the onlyIf condition of this + // task. Therefore, needsCodegenFromPackageJson needs to be invoked inside this + // lambda. + val needsCodegenFromPackageJson = + project.needsCodegenFromPackageJson(rootExtension.root) + val parsedPackageJson = packageJson?.let { JsonUtils.fromPackageJson(it) } + val includesGeneratedCode = + parsedPackageJson?.codegenConfig?.includesGeneratedCode ?: false + (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode + }, + ) // We update the android configuration to include the generated sources. // This is equivalent to this DSL: @@ -353,13 +355,14 @@ class ReactPlugin : Plugin { project.rootProject.layout.buildDirectory.file("generated/autolinking/autolinking.json") val pureCxxDependencies = getPureCxxCodegenDependencies(rootGeneratedAutolinkingFile.get().asFile) - val pureCxxCodegenTasks = configurePureCxxDependenciesCodegen( - project, - extension, - rootExtension, - generatedPureCxxSourceDir, - pureCxxDependencies, - ) + val pureCxxCodegenTasks = + configurePureCxxDependenciesCodegen( + project, + extension, + rootExtension, + generatedPureCxxSourceDir, + pureCxxDependencies, + ) // We add a task called generateAutolinkingPackageList to do not clash with the existing task // called generatePackageList. This can to be renamed once we unlink the rn <-> cli diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt index 1ed09caa17d..89ba3656a3e 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt @@ -109,12 +109,13 @@ abstract class BundleHermesCTask : DefaultTask() { val reactNativeDir = reactNativeDir.get().asFile val composeScriptFile = File(reactNativeDir, "scripts/compose-source-maps.js") - val composeSourceMapsCommand = getComposeSourceMapsCommand( - composeScriptFile, - packagerSourceMap, - compilerSourceMap, - outputSourceMap, - ) + val composeSourceMapsCommand = + getComposeSourceMapsCommand( + composeScriptFile, + packagerSourceMap, + compilerSourceMap, + outputSourceMap, + ) runCommand(composeSourceMapsCommand) } } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt index 7ba0cd1367a..6712e1a6b30 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt @@ -28,11 +28,12 @@ import org.gradle.api.file.DirectoryProperty internal fun detectedEntryFile( config: ReactExtension, envVariableOverride: String? = null, -): File = detectEntryFile( - entryFile = config.entryFile.orNull?.asFile, - reactRoot = config.root.get().asFile, - envVariableOverride = envVariableOverride, -) +): File = + detectEntryFile( + entryFile = config.entryFile.orNull?.asFile, + reactRoot = config.root.get().asFile, + envVariableOverride = envVariableOverride, + ) /** * Computes the CLI file for React Native. The Algo follows this order: @@ -41,11 +42,12 @@ internal fun detectedEntryFile( * 3. The `node_modules/react-native/cli.js` file if exists * 4. Fails otherwise */ -internal fun detectedCliFile(config: ReactExtension): File = detectCliFile( - project = config.project, - reactNativeRoot = config.root.get().asFile, - preconfiguredCliFile = config.cliFile.asFile.orNull, -) +internal fun detectedCliFile(config: ReactExtension): File = + detectCliFile( + project = config.project, + reactNativeRoot = config.root.get().asFile, + preconfiguredCliFile = config.cliFile.asFile.orNull, + ) /** * Computes the `hermesc` command location. The Algo follows this order: diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt index 5465988e59d..f19b140f442 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt @@ -127,11 +127,12 @@ class ReactPluginTest { @Test fun taskNameSuffixForDependency_withNonAlphanumericCharacters_encodesThem() { - val dependency = ModelAutolinkingDependenciesJson( - root = "./node_modules/@foo/bar-baz", - name = "@foo/bar-baz", - platforms = null, - ) + val dependency = + ModelAutolinkingDependenciesJson( + root = "./node_modules/@foo/bar-baz", + name = "@foo/bar-baz", + platforms = null, + ) val result = ReactPlugin().taskNameSuffixForDependency(dependency) @@ -143,11 +144,12 @@ class ReactPluginTest { val plugin = ReactPlugin() val suffixes = listOf("@foo/bar", "foo.bar", "foo-bar", "foo_bar", "foo_45_bar").map { name -> - val dependency = ModelAutolinkingDependenciesJson( - root = "./node_modules/$name", - name = name, - platforms = null, - ) + val dependency = + ModelAutolinkingDependenciesJson( + root = "./node_modules/$name", + name = name, + platforms = null, + ) plugin.taskNameSuffixForDependency(dependency) } @@ -157,11 +159,12 @@ class ReactPluginTest { @Test fun taskNameSuffixForDependency_withLocalModuleRoot_usesPackageName() { - val dependency = ModelAutolinkingDependenciesJson( - root = "./modules/local-module", - name = "local-module", - platforms = null, - ) + val dependency = + ModelAutolinkingDependenciesJson( + root = "./modules/local-module", + name = "local-module", + platforms = null, + ) val result = ReactPlugin().taskNameSuffixForDependency(dependency) diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJsonTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJsonTest.kt index 676d9dfee3f..53b32aaa6b8 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJsonTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJsonTest.kt @@ -36,13 +36,13 @@ class ModelAutolinkingDependenciesJsonTest { assertThat(ModelAutolinkingDependenciesJson("", "@react-native/package", null).nameCleansed) .isEqualTo("react-native_package") assertThat( - ModelAutolinkingDependenciesJson( - "", - "@this*is~a(more)complicated/example!of~weird)packages", - null, + ModelAutolinkingDependenciesJson( + "", + "@this*is~a(more)complicated/example!of~weird)packages", + null, + ) + .nameCleansed ) - .nameCleansed - ) .isEqualTo("this_is_a_more_complicated_example_of_weird_packages") } } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt index a2766d9c76c..df92f572e33 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt @@ -85,12 +85,13 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { @Test fun filterAndroidPackages_withValidAndroidObject_returnsIt() { val task = createTestTask() - val android = ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory/android", - packageImportPath = "import com.facebook.react.aPackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - ) + val android = + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory/android", + packageImportPath = "import com.facebook.react.aPackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + ) val result = task.filterAndroidPackages( @@ -115,15 +116,16 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { @Test fun cmakeListsPathForDependency_withCmakeListsPath_returnsIt() { val task = createTestTask() - val dependency = ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory", - packageImportPath = "import com.facebook.react.aPackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - libraryName = "aPackage", - cmakeListsPath = "./a/directory/CMakeLists.txt", - isPureCxxDependency = true, - ) + val dependency = + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory", + packageImportPath = "import com.facebook.react.aPackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + libraryName = "aPackage", + cmakeListsPath = "./a/directory/CMakeLists.txt", + isPureCxxDependency = true, + ) assertThat(task.cmakeListsPathForDependency(dependency)) .isEqualTo("./a/directory/CMakeLists.txt") @@ -136,14 +138,15 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { createTestTask { it.generatedPureCxxSourceDirectory.set(generatedPureCxxSourceDirectory) } - val dependency = ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory", - packageImportPath = "import com.facebook.react.aPackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - libraryName = "aPackage", - isPureCxxDependency = true, - ) + val dependency = + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory", + packageImportPath = "import com.facebook.react.aPackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + libraryName = "aPackage", + isPureCxxDependency = true, + ) assertThat(task.cmakeListsPathForDependency(dependency)) .isEqualTo( @@ -154,14 +157,15 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { @Test fun cmakeListsPathForDependency_withMissingGeneratedDirectory_returnsNull() { val task = createTestTask() - val dependency = ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory", - packageImportPath = "import com.facebook.react.aPackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - libraryName = "aPackage", - isPureCxxDependency = true, - ) + val dependency = + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory", + packageImportPath = "import com.facebook.react.aPackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + libraryName = "aPackage", + isPureCxxDependency = true, + ) assertThat(task.cmakeListsPathForDependency(dependency)).isNull() } @@ -173,14 +177,15 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { createTestTask { it.generatedPureCxxSourceDirectory.set(generatedPureCxxSourceDirectory) } - val dependency = ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory", - packageImportPath = "import com.facebook.react.aPackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - libraryName = "aPackage", - isPureCxxDependency = false, - ) + val dependency = + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory", + packageImportPath = "import com.facebook.react.aPackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + libraryName = "aPackage", + isPureCxxDependency = false, + ) assertThat(task.cmakeListsPathForDependency(dependency)).isNull() } @@ -498,27 +503,28 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { assertThat(sanitizeCmakeListsPath(input)).isEqualTo("./a/dir\\ ectory/") } - private val testDependencies = listOf( - ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory", - packageImportPath = "import com.facebook.react.aPackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - libraryName = "aPackage", - componentDescriptors = emptyList(), - cmakeListsPath = "./a/directory/CMakeLists.txt", - ), - ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./another/directory", - packageImportPath = "import com.facebook.react.anotherPackage;", - packageInstance = "new AnotherPackage()", - buildTypes = emptyList(), - libraryName = "anotherPackage", - componentDescriptors = listOf("AnotherPackageComponentDescriptor"), - cmakeListsPath = "./another/directory/with spaces/CMakeLists.txt", - cxxModuleCMakeListsPath = "./another/directory/cxx/CMakeLists.txt", - cxxModuleHeaderName = "AnotherCxxModule", - cxxModuleCMakeListsModuleName = "another_cxxModule", - ), - ) + private val testDependencies = + listOf( + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory", + packageImportPath = "import com.facebook.react.aPackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + libraryName = "aPackage", + componentDescriptors = emptyList(), + cmakeListsPath = "./a/directory/CMakeLists.txt", + ), + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./another/directory", + packageImportPath = "import com.facebook.react.anotherPackage;", + packageInstance = "new AnotherPackage()", + buildTypes = emptyList(), + libraryName = "anotherPackage", + componentDescriptors = listOf("AnotherPackageComponentDescriptor"), + cmakeListsPath = "./another/directory/with spaces/CMakeLists.txt", + cxxModuleCMakeListsPath = "./another/directory/cxx/CMakeLists.txt", + cxxModuleHeaderName = "AnotherCxxModule", + cxxModuleCMakeListsModuleName = "another_cxxModule", + ), + ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt index d66f80afecc..f8e455356a5 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt @@ -151,12 +151,13 @@ class GeneratePackageListTaskTest { @Test fun filterAndroidPackages_withValidAndroidObject_returnsIt() { val task = createTestTask() - val android = ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory/android", - packageImportPath = "import com.facebook.react.aPackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - ) + val android = + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory/android", + packageImportPath = "import com.facebook.react.aPackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + ) val result = task.filterAndroidPackages( @@ -182,13 +183,14 @@ class GeneratePackageListTaskTest { @Test fun filterAndroidPackages_withIsPureCxxDependencyObject_returnsIt() { val task = createTestTask() - val android = ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory/android", - packageImportPath = "import com.facebook.react.aPackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - isPureCxxDependency = true, - ) + val android = + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory/android", + packageImportPath = "import com.facebook.react.aPackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + isPureCxxDependency = true, + ) val result = task.filterAndroidPackages( @@ -364,26 +366,27 @@ class GeneratePackageListTaskTest { ) } - private val testDependencies = mapOf( - "@react-native/a-package" to - ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./a/directory", - packageImportPath = "import com.facebook.react.APackage;", - packageInstance = "new APackage()", - buildTypes = emptyList(), - libraryName = "aPackage", - componentDescriptors = emptyList(), - cmakeListsPath = "./a/directory/CMakeLists.txt", - ), - "@react-native/another-package" to - ModelAutolinkingDependenciesPlatformAndroidJson( - sourceDir = "./another/directory", - packageImportPath = "import com.facebook.react.AnotherPackage;", - packageInstance = "new AnotherPackage()", - buildTypes = emptyList(), - libraryName = "anotherPackage", - componentDescriptors = emptyList(), - cmakeListsPath = "./another/directory/CMakeLists.txt", - ), - ) + private val testDependencies = + mapOf( + "@react-native/a-package" to + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./a/directory", + packageImportPath = "import com.facebook.react.APackage;", + packageInstance = "new APackage()", + buildTypes = emptyList(), + libraryName = "aPackage", + componentDescriptors = emptyList(), + cmakeListsPath = "./a/directory/CMakeLists.txt", + ), + "@react-native/another-package" to + ModelAutolinkingDependenciesPlatformAndroidJson( + sourceDir = "./another/directory", + packageImportPath = "import com.facebook.react.AnotherPackage;", + packageInstance = "new AnotherPackage()", + buildTypes = emptyList(), + libraryName = "anotherPackage", + componentDescriptors = emptyList(), + cmakeListsPath = "./another/directory/CMakeLists.txt", + ), + ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntryTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntryTest.kt index dbff6173649..b83c26d4687 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntryTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntryTest.kt @@ -14,10 +14,11 @@ class PrefabPreprocessingEntryTest { @Test fun secondaryConstructor_createsAList() { - val sampleEntry = PrefabPreprocessingEntry( - libraryName = "justALibrary", - pathToPrefixCouple = "aPath" to "andAPrefix", - ) + val sampleEntry = + PrefabPreprocessingEntry( + libraryName = "justALibrary", + pathToPrefixCouple = "aPath" to "andAPrefix", + ) assertThat(sampleEntry.pathToPrefixCouples.size).isEqualTo(1) assertThat(sampleEntry.pathToPrefixCouples[0].first).isEqualTo("aPath") diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt index c4b2ff7a5b7..8df848836a9 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt @@ -807,13 +807,14 @@ class DependencyUtilsTest { @Test fun isNightly_returnsTrue_forValidNightlyVersions() { - val trueCases = listOf( - "0.85.0-nightly-20260128-36f07a1b2", - "0.82.0-nightly-date-commit", - "0.0.0-20230505-2109-9b69263a1", - "0.0.0-date-commit", - "0.0.0-nightly-", - ) + val trueCases = + listOf( + "0.85.0-nightly-20260128-36f07a1b2", + "0.82.0-nightly-date-commit", + "0.0.0-20230505-2109-9b69263a1", + "0.0.0-date-commit", + "0.0.0-nightly-", + ) trueCases.forEach { version -> assert(version.isNightly()) { "Expected '$version' to be detected as nightly" } @@ -822,16 +823,17 @@ class DependencyUtilsTest { @Test fun isNightly_returnsFalse_forNonNightlyVersions() { - val falseCases = listOf( - "0.83.0", // Standard version - "0.0.1", - "nightly", // Missing hyphens - "0.83.0-nightly", // Missing trailing hyphen - "any-nightly", // Missing trailing hyphen - "nightly-build", // Missing leading hyphen - "", // Empty string - " ", // Blank string - ) + val falseCases = + listOf( + "0.83.0", // Standard version + "0.0.1", + "nightly", // Missing hyphens + "0.83.0-nightly", // Missing trailing hyphen + "any-nightly", // Missing trailing hyphen + "nightly-build", // Missing leading hyphen + "", // Empty string + " ", // Blank string + ) falseCases.forEach { version -> assert(!version.isNightly()) { "Expected '$version' to NOT be detected as nightly" } diff --git a/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/PopupMenuPackage.kt b/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/PopupMenuPackage.kt index 93a4bfc50a9..199713731ad 100644 --- a/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/PopupMenuPackage.kt +++ b/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/PopupMenuPackage.kt @@ -18,9 +18,11 @@ import com.facebook.react.uimanager.ViewManager @ReactModuleList(nativeModules = arrayOf()) public class PopupMenuPackage() : BaseReactPackage(), ViewManagerOnDemandReactPackage { - private val viewManagersMap: Map = mapOf( - ReactPopupMenuManager.REACT_CLASS to ModuleSpec.viewManagerSpec({ ReactPopupMenuManager() }), - ) + private val viewManagersMap: Map = + mapOf( + ReactPopupMenuManager.REACT_CLASS to + ModuleSpec.viewManagerSpec({ ReactPopupMenuManager() }), + ) override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? { return null diff --git a/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/ReactPopupMenuManager.kt b/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/ReactPopupMenuManager.kt index 756bfa702ab..17b3376d558 100644 --- a/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/ReactPopupMenuManager.kt +++ b/packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/popupmenu/ReactPopupMenuManager.kt @@ -53,10 +53,11 @@ public class ReactPopupMenuManager : public companion object { public const val REACT_CLASS: String = "AndroidPopupMenu" private const val REGISTRATION_NAME = "registrationName" - private val DIRECT_EVENT_TYPE_CONSTANT = mapOf( - PopupMenuSelectionEvent.EVENT_NAME to - mapOf(REGISTRATION_NAME to "onPopupMenuSelectionChange"), - PopupMenuDismissEvent.EVENT_NAME to mapOf(REGISTRATION_NAME to "onPopupMenuDismiss"), - ) + private val DIRECT_EVENT_TYPE_CONSTANT = + mapOf( + PopupMenuSelectionEvent.EVENT_NAME to + mapOf(REGISTRATION_NAME to "onPopupMenuSelectionChange"), + PopupMenuDismissEvent.EVENT_NAME to mapOf(REGISTRATION_NAME to "onPopupMenuDismiss"), + ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt index 40089646df0..faf64f2a64f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt @@ -28,9 +28,10 @@ internal object ReactDebugOverlayTags { val NATIVE_MODULE: DebugOverlayTag = DebugOverlayTag("Native Module", "Native Module init", Color.rgb(0x80, 0x00, 0x80)) @JvmField - val UI_MANAGER: DebugOverlayTag = DebugOverlayTag( - "UI Manager", - "UI Manager View Operations (requires restart\nwarning: this is spammy)", - Color.CYAN, - ) + val UI_MANAGER: DebugOverlayTag = + DebugOverlayTag( + "UI Manager", + "UI Manager View Operations (requires restart\nwarning: this is spammy)", + Color.CYAN, + ) } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt index 22388c9fbef..42e01e8304c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt @@ -75,26 +75,27 @@ internal class ReactAndroidHWInputDeviceHelper { * Contains a mapping between handled KeyEvents and the corresponding navigation event that * should be fired when the KeyEvent is received. */ - private val KEY_EVENTS_ACTIONS: Map = mapOf( - KeyEvent.KEYCODE_DPAD_CENTER to "select", - KeyEvent.KEYCODE_ENTER to "select", - KeyEvent.KEYCODE_SPACE to "select", - KeyEvent.KEYCODE_MEDIA_PLAY to "play", - KeyEvent.KEYCODE_MEDIA_PAUSE to "pause", - KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE to "playPause", - KeyEvent.KEYCODE_MEDIA_REWIND to "rewind", - KeyEvent.KEYCODE_MEDIA_FAST_FORWARD to "fastForward", - KeyEvent.KEYCODE_MEDIA_STOP to "stop", - KeyEvent.KEYCODE_MEDIA_NEXT to "next", - KeyEvent.KEYCODE_MEDIA_PREVIOUS to "previous", - KeyEvent.KEYCODE_DPAD_UP to "up", - KeyEvent.KEYCODE_DPAD_RIGHT to "right", - KeyEvent.KEYCODE_DPAD_DOWN to "down", - KeyEvent.KEYCODE_DPAD_LEFT to "left", - KeyEvent.KEYCODE_INFO to "info", - KeyEvent.KEYCODE_MENU to "menu", - KeyEvent.KEYCODE_CHANNEL_UP to "channelUp", - KeyEvent.KEYCODE_CHANNEL_DOWN to "channelDown", - ) + private val KEY_EVENTS_ACTIONS: Map = + mapOf( + KeyEvent.KEYCODE_DPAD_CENTER to "select", + KeyEvent.KEYCODE_ENTER to "select", + KeyEvent.KEYCODE_SPACE to "select", + KeyEvent.KEYCODE_MEDIA_PLAY to "play", + KeyEvent.KEYCODE_MEDIA_PAUSE to "pause", + KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE to "playPause", + KeyEvent.KEYCODE_MEDIA_REWIND to "rewind", + KeyEvent.KEYCODE_MEDIA_FAST_FORWARD to "fastForward", + KeyEvent.KEYCODE_MEDIA_STOP to "stop", + KeyEvent.KEYCODE_MEDIA_NEXT to "next", + KeyEvent.KEYCODE_MEDIA_PREVIOUS to "previous", + KeyEvent.KEYCODE_DPAD_UP to "up", + KeyEvent.KEYCODE_DPAD_RIGHT to "right", + KeyEvent.KEYCODE_DPAD_DOWN to "down", + KeyEvent.KEYCODE_DPAD_LEFT to "left", + KeyEvent.KEYCODE_INFO to "info", + KeyEvent.KEYCODE_MENU to "menu", + KeyEvent.KEYCODE_CHANNEL_UP to "channelUp", + KeyEvent.KEYCODE_CHANNEL_DOWN to "channelDown", + ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt index aeb74a2767e..236bf26239e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.kt @@ -260,15 +260,16 @@ internal class InterpolationAnimatedNode(config: ReadableMap) : ValueAnimatedNod val m = numericPattern.matcher(pattern) var i = 0 while (m.find() && i < outputRange[rangeIndex].size) { - val v = interpolate( - value, - inputRange[rangeIndex], - inputRange[rangeIndex + 1], - outputRange[rangeIndex][i], - outputRange[rangeIndex + 1][i], - extrapolateLeft, - extrapolateRight, - ) + val v = + interpolate( + value, + inputRange[rangeIndex], + inputRange[rangeIndex + 1], + outputRange[rangeIndex][i], + outputRange[rangeIndex + 1][i], + extrapolateLeft, + extrapolateRight, + ) val intVal = v.toInt() m.appendReplacement(sb, if (intVal.toDouble() != v) v.toString() else intVal.toString()) i++ diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt index 4e29037207a..dbc15af9927 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt @@ -142,17 +142,18 @@ private constructor( exceptionHandler: QueueThreadExceptionHandler, ): MessageQueueThreadImpl { val looperFuture = SimpleSettableFuture() - val bgThread = Thread( - null, - { - Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY) - Looper.prepare() - looperFuture.set(Looper.myLooper()) - Looper.loop() - }, - "mqt_$name", - stackSize, - ) + val bgThread = + Thread( + null, + { + Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY) + Looper.prepare() + looperFuture.set(Looper.myLooper()) + Looper.loop() + }, + "mqt_$name", + stackSize, + ) bgThread.start() val looper = diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/ReactQueueConfigurationSpec.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/ReactQueueConfigurationSpec.kt index 1d6f3e7cac2..310ec3249ef 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/ReactQueueConfigurationSpec.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/ReactQueueConfigurationSpec.kt @@ -44,9 +44,10 @@ public constructor( public fun builder(): Builder = Builder() @JvmStatic - public fun createDefault(): ReactQueueConfigurationSpec = ReactQueueConfigurationSpec( - newBackgroundThreadSpec("native_modules"), - newBackgroundThreadSpec("js"), - ) + public fun createDefault(): ReactQueueConfigurationSpec = + ReactQueueConfigurationSpec( + newBackgroundThreadSpec("native_modules"), + newBackgroundThreadSpec("js"), + ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt index 8a01895c6cf..a2b934f830f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt @@ -87,25 +87,27 @@ public object DefaultReactHost { } val defaultTmmDelegateBuilder = DefaultTurboModuleManagerDelegate.Builder() cxxReactPackageProviders.forEach { defaultTmmDelegateBuilder.addCxxReactPackage(it) } - val defaultReactHostDelegate = DefaultReactHostDelegate( - jsMainModulePath = jsMainModulePath, - jsBundleLoader = bundleLoader, - reactPackages = packageList, - jsRuntimeFactory = jsRuntimeFactory ?: HermesInstance(), - bindingsInstaller = bindingsInstaller, - turboModuleManagerDelegateBuilder = defaultTmmDelegateBuilder, - exceptionHandler = exceptionHandler, - ) + val defaultReactHostDelegate = + DefaultReactHostDelegate( + jsMainModulePath = jsMainModulePath, + jsBundleLoader = bundleLoader, + reactPackages = packageList, + jsRuntimeFactory = jsRuntimeFactory ?: HermesInstance(), + bindingsInstaller = bindingsInstaller, + turboModuleManagerDelegateBuilder = defaultTmmDelegateBuilder, + exceptionHandler = exceptionHandler, + ) val componentFactory = ComponentFactory() DefaultComponentsRegistry.register(componentFactory) // TODO: T164788699 find alternative of accessing ReactHostImpl for initialising reactHost - val newReactHost = ReactHostImpl( - context, - defaultReactHostDelegate, - componentFactory, - true /* allowPackagerServerAccess */, - useDevSupport, - ) + val newReactHost = + ReactHostImpl( + context, + defaultReactHostDelegate, + componentFactory, + true /* allowPackagerServerAccess */, + useDevSupport, + ) reactHost = newReactHost return newReactHost } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultTurboModuleManagerDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultTurboModuleManagerDelegate.kt index 3674eccfd30..becc5987e78 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultTurboModuleManagerDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultTurboModuleManagerDelegate.kt @@ -59,11 +59,12 @@ private constructor( override fun build( context: ReactApplicationContext, packages: List, - ): DefaultTurboModuleManagerDelegate = DefaultTurboModuleManagerDelegate( - context, - packages, - cxxReactPackageProviders.flatMap { provider -> provider(context) }, - ) + ): DefaultTurboModuleManagerDelegate = + DefaultTurboModuleManagerDelegate( + context, + packages, + cxxReactPackageProviders.flatMap { provider -> provider(context) }, + ) } private companion object { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.kt index 6947cb064f0..79f13c0e66e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.kt @@ -61,10 +61,11 @@ internal class DebugOverlayController(private val reactContext: ReactContext) { fun requestPermission(context: Context) { // Get permission to show debug overlay in dev builds. if (!Settings.canDrawOverlays(context)) { - val intent = Intent( - Settings.ACTION_MANAGE_OVERLAY_PERMISSION, - Uri.parse("package:" + context.packageName), - ) + val intent = + Intent( + Settings.ACTION_MANAGE_OVERLAY_PERMISSION, + Uri.parse("package:" + context.packageName), + ) intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) FLog.w( ReactConstants.TAG, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevLoadingViewImplementation.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevLoadingViewImplementation.kt index d8bb1dc5355..ae2753ef44c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevLoadingViewImplementation.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevLoadingViewImplementation.kt @@ -140,11 +140,12 @@ public class DefaultDevLoadingViewImplementation( // Allow tapping anywhere on the banner to dismiss rootView.setOnClickListener { hideInternal() } - val popup = PopupWindow( - rootView, - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT, - ) + val popup = + PopupWindow( + rootView, + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT, + ) popup.showAtLocation(currentActivity.window.decorView, Gravity.NO_GRAVITY, 0, topOffset) devLoadingView = textView // Store the TextView for updateProgress() devLoadingPopup = popup diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt index bae2ace113f..127b6a8dbee 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt @@ -176,11 +176,11 @@ public open class DevServerHelper( checkNotNull(clientId) packagerClient = JSPackagerClient( - clientId, - packagerConnectionSettings, - handlers, - onPackagerConnectedCallback, - ) + clientId, + packagerConnectionSettings, + handlers, + onPackagerConnectedCallback, + ) .apply { init() } return null @@ -217,10 +217,10 @@ public open class DevServerHelper( } inspectorPackagerConnection = CxxInspectorPackagerConnection( - this@DevServerHelper.inspectorDeviceUrl, - deviceName, - packageName, - ) + this@DevServerHelper.inspectorDeviceUrl, + deviceName, + packageName, + ) .apply { connect() } return null } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt index 1e18107468c..0608c07b78b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt @@ -107,14 +107,15 @@ public abstract class DevSupportManagerBase( public final override var currentReactContext: ReactContext? = null private set - public final override val devSettings: DeveloperSettings = DevInternalSettings( - applicationContext, - object : DevInternalSettings.Listener { - override fun onInternalSettingsChanged() { - this@DevSupportManagerBase.reloadSettings() - } - }, - ) + public final override val devSettings: DeveloperSettings = + DevInternalSettings( + applicationContext, + object : DevInternalSettings.Listener { + override fun onInternalSettingsChanged() { + this@DevSupportManagerBase.reloadSettings() + } + }, + ) override val currentActivity: Activity? get() = reactInstanceDevHelper.currentActivity diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt index b9f75d1f1dd..f0cd50b3cda 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt @@ -18,12 +18,13 @@ internal class PerftestDevSupportManager( applicationContext: Context, ) : ReleaseDevSupportManager() { - override val devSettings: DeveloperSettings = DevInternalSettings( - applicationContext, - object : DevInternalSettings.Listener { - override fun onInternalSettingsChanged() = Unit - }, - ) + override val devSettings: DeveloperSettings = + DevInternalSettings( + applicationContext, + object : DevInternalSettings.Listener { + override fun onInternalSettingsChanged() = Unit + }, + ) private val devServerHelper: DevServerHelper = DevServerHelper(devSettings, applicationContext, devSettings.packagerConnectionSettings) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxContentView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxContentView.kt index 3868216247a..3d7b7626165 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxContentView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxContentView.kt @@ -181,14 +181,15 @@ internal class RedBoxContentView( companion object { private val JSON: MediaType? = MediaType.parse("application/json; charset=utf-8") - private fun stackFrameToJson(frame: StackFrame) = JSONObject( - mapOf( - "file" to frame.file, - "methodName" to frame.method, - "lineNumber" to frame.line, - "column" to frame.column, + private fun stackFrameToJson(frame: StackFrame) = + JSONObject( + mapOf( + "file" to frame.file, + "methodName" to frame.method, + "lineNumber" to frame.line, + "column" to frame.column, + ) ) - ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.kt index 6b8c5daaa2c..77c40e2e07b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.kt @@ -248,14 +248,15 @@ public object StackTraceHelper { ) : StackFrame { /** Convert the stack frame to a JSON representation. */ - override fun toJSON(): JSONObject = JSONObject( - mapOf( - FILE_KEY to (file.orEmpty()), - METHOD_NAME_KEY to method, - LINE_NUMBER_KEY to line, - COLUMN_KEY to column, - COLLAPSE_KEY to isCollapsed, + override fun toJSON(): JSONObject = + JSONObject( + mapOf( + FILE_KEY to (file.orEmpty()), + METHOD_NAME_KEY to method, + LINE_NUMBER_KEY to line, + COLUMN_KEY to column, + COLLAPSE_KEY to isCollapsed, + ) ) - ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt index edb39de7bdd..4e62a431816 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt @@ -129,12 +129,13 @@ internal class ViewTransitionSnapshotManager( // and the partial result gets stretched to fill the pseudo-element. val windowWidth = window.decorView.width val windowHeight = window.decorView.height - val clampedRect = Rect( - viewRect.left.coerceAtLeast(0), - viewRect.top.coerceAtLeast(0), - viewRect.right.coerceAtMost(windowWidth), - viewRect.bottom.coerceAtMost(windowHeight), - ) + val clampedRect = + Rect( + viewRect.left.coerceAtLeast(0), + viewRect.top.coerceAtLeast(0), + viewRect.right.coerceAtMost(windowWidth), + viewRect.bottom.coerceAtMost(windowHeight), + ) if (clampedRect.isEmpty) { // Entirely off-screen — nothing to capture. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt index 8a06e0d1a67..48410a98298 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt @@ -64,14 +64,15 @@ internal class MountingManager( reactContext: ThemedReactContext?, rootView: View?, ): SurfaceMountingManager { - val surfaceMountingManager = SurfaceMountingManager( - surfaceId, - jsResponderHandler, - viewManagerRegistry, - rootViewManager, - mountItemExecutor, - checkNotNull(reactContext), - ) + val surfaceMountingManager = + SurfaceMountingManager( + surfaceId, + jsResponderHandler, + viewManagerRegistry, + rootViewManager, + mountItemExecutor, + checkNotNull(reactContext), + ) // There could technically be a race condition here if addRootView is called twice from // different threads, though this is (probably) extremely unlikely, and likely an error. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.kt index 8721e35b753..31d93c32b69 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.kt @@ -9,27 +9,28 @@ package com.facebook.react.fabric.mounting.mountitems /** Utility class for Fabric components, this will be removed */ internal object FabricNameComponentMapping { - private val componentNames: Map = mapOf( - // TODO T97384889: unify component names between JS - Android - iOS - C++ - "View" to "RCTView", - "Image" to "RCTImageView", - "ScrollView" to "RCTScrollView", - "Slider" to "RCTSlider", - "ModalHostView" to "RCTModalHostView", - "Paragraph" to "RCTText", - "SelectableParagraph" to "RCTSelectableText", - "Text" to "RCTText", - "RawText" to "RCTRawText", - "ActivityIndicatorView" to "AndroidProgressBar", - "ShimmeringView" to "RKShimmeringView", - "TemplateView" to "RCTTemplateView", - "AxialGradientView" to "RCTAxialGradientView", - "Video" to "RCTVideo", - "Map" to "RCTMap", - "WebView" to "RCTWebView", - "Keyframes" to "RCTKeyframes", - "ImpressionTrackingView" to "RCTImpressionTrackingView", - ) + private val componentNames: Map = + mapOf( + // TODO T97384889: unify component names between JS - Android - iOS - C++ + "View" to "RCTView", + "Image" to "RCTImageView", + "ScrollView" to "RCTScrollView", + "Slider" to "RCTSlider", + "ModalHostView" to "RCTModalHostView", + "Paragraph" to "RCTText", + "SelectableParagraph" to "RCTSelectableText", + "Text" to "RCTText", + "RawText" to "RCTRawText", + "ActivityIndicatorView" to "AndroidProgressBar", + "ShimmeringView" to "RKShimmeringView", + "TemplateView" to "RCTTemplateView", + "AxialGradientView" to "RCTAxialGradientView", + "Video" to "RCTVideo", + "Map" to "RCTMap", + "WebView" to "RCTWebView", + "Keyframes" to "RCTKeyframes", + "ImpressionTrackingView" to "RCTImpressionTrackingView", + ) /** @return the name of component in the Fabric environment */ @JvmStatic diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt index f83c7260241..5a55e7c8050 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt @@ -50,11 +50,12 @@ public class TurboModuleManager( @Suppress("NoHungarianNotation") @DoNotStrip - private val mHybridData: HybridData = initHybrid( - jsCallInvokerHolder as CallInvokerHolderImpl, - nativeMethodCallInvokerHolder as NativeMethodCallInvokerHolderImpl, - delegate, - ) + private val mHybridData: HybridData = + initHybrid( + jsCallInvokerHolder as CallInvokerHolderImpl, + nativeMethodCallInvokerHolder as NativeMethodCallInvokerHolderImpl, + delegate, + ) init { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.kt index 98900181455..faad9b4df7c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.kt @@ -117,13 +117,14 @@ public class HeadlessJsTaskContext private constructor(reactContext: ReactContex } removeTimeout(taskId) - val taskConfig = HeadlessJsTaskConfig( - sourceTaskConfig.taskKey, - sourceTaskConfig.data, - sourceTaskConfig.timeout, - sourceTaskConfig.isAllowedInForeground, - retryPolicy.update(), - ) + val taskConfig = + HeadlessJsTaskConfig( + sourceTaskConfig.taskKey, + sourceTaskConfig.data, + sourceTaskConfig.timeout, + sourceTaskConfig.isAllowedInForeground, + retryPolicy.update(), + ) val retryAttempt = Runnable { startTask(taskConfig, taskId) } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.kt index 4a78c7b33dd..984bc8aaa70 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.kt @@ -191,12 +191,13 @@ public class DialogModule(reactContext: ReactApplicationContext?) : private const val KEY_ITEMS: String = "items" private const val KEY_CANCELABLE: String = "cancelable" - private val CONSTANTS: Map = mapOf( - ACTION_BUTTON_CLICKED to ACTION_BUTTON_CLICKED, - ACTION_DISMISSED to ACTION_DISMISSED, - KEY_BUTTON_POSITIVE to DialogInterface.BUTTON_POSITIVE, - KEY_BUTTON_NEGATIVE to DialogInterface.BUTTON_NEGATIVE, - KEY_BUTTON_NEUTRAL to DialogInterface.BUTTON_NEUTRAL, - ) + private val CONSTANTS: Map = + mapOf( + ACTION_BUTTON_CLICKED to ACTION_BUTTON_CLICKED, + ACTION_DISMISSED to ACTION_DISMISSED, + KEY_BUTTON_POSITIVE to DialogInterface.BUTTON_POSITIVE, + KEY_BUTTON_NEGATIVE to DialogInterface.BUTTON_NEGATIVE, + KEY_BUTTON_NEUTRAL to DialogInterface.BUTTON_NEUTRAL, + ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt index c1b330157b2..c7f5b85b822 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt @@ -378,32 +378,33 @@ public class NetworkingModule( clientBuilder.addNetworkInterceptor { chain -> val originalResponse = chain.proceed(chain.request()) val originalResponseBody = checkNotNull(originalResponse.body()) - val responseBody = ProgressResponseBody( - originalResponseBody, - object : ProgressListener { - var last: Long = System.nanoTime() - - override fun onProgress(bytesWritten: Long, contentLength: Long, done: Boolean) { - val now = System.nanoTime() - if (!done && !shouldDispatch(now, last)) { - return - } - if (responseType == "text") { - // For 'text' responses we continuously send response data with progress - // info to - // JS below, so no need to do anything here. - return - } - NetworkEventUtil.onDataReceivedProgress( - reactApplicationContext, - requestId, - bytesWritten, - contentLength, - ) - last = now - } - }, - ) + val responseBody = + ProgressResponseBody( + originalResponseBody, + object : ProgressListener { + var last: Long = System.nanoTime() + + override fun onProgress(bytesWritten: Long, contentLength: Long, done: Boolean) { + val now = System.nanoTime() + if (!done && !shouldDispatch(now, last)) { + return + } + if (responseType == "text") { + // For 'text' responses we continuously send response data with progress + // info to + // JS below, so no need to do anything here. + return + } + NetworkEventUtil.onDataReceivedProgress( + reactApplicationContext, + requestId, + bytesWritten, + contentLength, + ) + last = now + } + }, + ) originalResponse.newBuilder().body(responseBody).build() } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt index 2ea8110568b..eeffccfab38 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt @@ -20,13 +20,14 @@ import com.facebook.react.module.annotations.ReactModule internal class ToastModule(reactContext: ReactApplicationContext) : NativeToastAndroidSpec(reactContext) { - override fun getTypedExportedConstants(): Map = mutableMapOf( - DURATION_SHORT_KEY to Toast.LENGTH_SHORT, - DURATION_LONG_KEY to Toast.LENGTH_LONG, - GRAVITY_TOP_KEY to (Gravity.TOP or Gravity.CENTER_HORIZONTAL), - GRAVITY_BOTTOM_KEY to (Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL), - GRAVITY_CENTER to (Gravity.CENTER_HORIZONTAL or Gravity.CENTER_VERTICAL), - ) + override fun getTypedExportedConstants(): Map = + mutableMapOf( + DURATION_SHORT_KEY to Toast.LENGTH_SHORT, + DURATION_LONG_KEY to Toast.LENGTH_LONG, + GRAVITY_TOP_KEY to (Gravity.TOP or Gravity.CENTER_HORIZONTAL), + GRAVITY_BOTTOM_KEY to (Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL), + GRAVITY_CENTER to (Gravity.CENTER_HORIZONTAL or Gravity.CENTER_VERTICAL), + ) override fun show(message: String?, durationDouble: Double) { val duration = durationDouble.toInt() diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt index 18d72c15886..560281dc501 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt @@ -89,17 +89,18 @@ internal class CoreReactPackage( private fun fallbackForMissingClass(): ReactModuleInfoProvider { // In OSS case, the annotation processor does not run. We fall back on creating this byhand - val moduleList: Array> = arrayOf>( - AndroidInfoModule::class.java, - DeviceInfoModule::class.java, - SourceCodeModule::class.java, - DevMenuModule::class.java, - DevSettingsModule::class.java, - DeviceEventManagerModule::class.java, - LogBoxModule::class.java, - ExceptionsManagerModule::class.java, - HeadlessJsTaskSupportModule::class.java, - ) + val moduleList: Array> = + arrayOf>( + AndroidInfoModule::class.java, + DeviceInfoModule::class.java, + SourceCodeModule::class.java, + DevMenuModule::class.java, + DevSettingsModule::class.java, + DeviceEventManagerModule::class.java, + LogBoxModule::class.java, + ExceptionsManagerModule::class.java, + HeadlessJsTaskSupportModule::class.java, + ) val reactModuleInfoMap: MutableMap = HashMap() for (moduleClass in moduleList) { val reactModule = moduleClass.getAnnotation(ReactModule::class.java) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt index aa303d00ff0..56ffb409268 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt @@ -1033,15 +1033,16 @@ public class ReactHostImpl( reactContext.jsExceptionHandler = devSupportManager stateTracker.enterState(method, "Creating ReactInstance") - val instance = ReactInstance( - reactContext, - reactHostDelegate, - componentFactory, - devSupportManager, - { e: Exception -> this.handleHostException(e) }, - useDevSupport, - getOrCreateReactHostInspectorTarget(), - ) + val instance = + ReactInstance( + reactContext, + reactHostDelegate, + componentFactory, + devSupportManager, + { e: Exception -> this.handleHostException(e) }, + useDevSupport, + getOrCreateReactHostInspectorTarget(), + ) reactInstance = instance val memoryPressureListener = createMemoryPressureListener(instance) @@ -1601,12 +1602,13 @@ public class ReactHostImpl( TracingState.ENABLED_IN_BACKGROUND_MODE, TracingState.ENABLED_IN_CDP_MODE -> { if (InspectorFlags.getFrameRecordingEnabled()) { - val observer = FrameTimingsObserver( - _screenshotsEnabled, - { frameTimingsSequence -> - inspectorTarget.recordFrameTimings(frameTimingsSequence) - }, - ) + val observer = + FrameTimingsObserver( + _screenshotsEnabled, + { frameTimingsSequence -> + inspectorTarget.recordFrameTimings(frameTimingsSequence) + }, + ) observer.setCurrentWindow(currentActivity?.window) observer.start() frameTimingsObserver = observer diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt index e6160b2eba2..63b6802ad3d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt @@ -119,10 +119,11 @@ internal class ReactInstance( * Prepare the ReactInstance by installing JSI bindings, initializing Fabric + TurboModules, and * loading the JS bundle. */ - val spec = ReactQueueConfigurationSpec( - MessageQueueThreadSpec.newBackgroundThreadSpec("v_native"), - MessageQueueThreadSpec.newBackgroundThreadSpec("v_js"), - ) + val spec = + ReactQueueConfigurationSpec( + MessageQueueThreadSpec.newBackgroundThreadSpec("v_native"), + MessageQueueThreadSpec.newBackgroundThreadSpec("v_js"), + ) reactQueueConfiguration = ReactQueueConfigurationImpl.create(spec, exceptionHandler) FLog.d(TAG, "Calling initializeMessageQueueThreads()") context.initializeMessageQueueThreads(reactQueueConfiguration) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.kt index afc24484c10..4341d3577de 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.kt @@ -167,16 +167,17 @@ public class Task : TaskInterface { public fun onSuccess( continuation: Continuation, executor: Executor = IMMEDIATE_EXECUTOR, - ): Task = continueWithTask( - { task -> - when { - task.isCancelled() -> cancelled() - task.isFaulted() -> forError(task.getError()) - else -> task.continueWith(continuation) - } - }, - executor, - ) + ): Task = + continueWithTask( + { task -> + when { + task.isCancelled() -> cancelled() + task.isFaulted() -> forError(task.getError()) + else -> task.continueWith(continuation) + } + }, + executor, + ) /** * Runs a continuation when a task completes successfully, forwarding along [java.lang.Exception]s @@ -185,16 +186,17 @@ public class Task : TaskInterface { public fun onSuccessTask( continuation: Continuation>, executor: Executor = IMMEDIATE_EXECUTOR, - ): Task = continueWithTask( - { task -> - when { - task.isCancelled() -> cancelled() - task.isFaulted() -> forError(task.getError()) - else -> task.continueWithTask(continuation) - } - }, - executor, - ) + ): Task = + continueWithTask( + { task -> + when { + task.isCancelled() -> cancelled() + task.isFaulted() -> forError(task.getError()) + else -> task.continueWithTask(continuation) + } + }, + executor, + ) private fun runContinuations() = synchronized(lock) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt index 16b6e5c56ad..be24b4d6209 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt @@ -137,29 +137,28 @@ constructor(private val config: MainPackageConfig? = null) : } @Suppress("DEPRECATION") - override fun createViewManagers( - reactContext: ReactApplicationContext - ): List> = listOf( - ReactDrawerLayoutManager(), - ReactHorizontalScrollViewManager(), - ReactHorizontalScrollContainerViewManager(), - ReactProgressBarViewManager(), - if (ReactNativeFeatureFlags.useNestedScrollViewAndroid()) ReactNestedScrollViewManager() - else ReactScrollViewManager(), - ReactSwitchManager(), - ReactSafeAreaViewManager(), - SwipeRefreshLayoutManager(), - // Native equivalents - ReactImageManager(), - ReactModalHostManager(), - ReactTextInputManager(), - if (ReactNativeFeatureFlags.enablePreparedTextLayout()) PreparedLayoutTextViewManager() - else ReactTextViewManager(), - SelectableTextViewManager(), - ReactViewManager(), - ReactVirtualViewManager(), - ReactUnimplementedViewManager(), - ) + override fun createViewManagers(reactContext: ReactApplicationContext): List> = + listOf( + ReactDrawerLayoutManager(), + ReactHorizontalScrollViewManager(), + ReactHorizontalScrollContainerViewManager(), + ReactProgressBarViewManager(), + if (ReactNativeFeatureFlags.useNestedScrollViewAndroid()) ReactNestedScrollViewManager() + else ReactScrollViewManager(), + ReactSwitchManager(), + ReactSafeAreaViewManager(), + SwipeRefreshLayoutManager(), + // Native equivalents + ReactImageManager(), + ReactModalHostManager(), + ReactTextInputManager(), + if (ReactNativeFeatureFlags.enablePreparedTextLayout()) PreparedLayoutTextViewManager() + else ReactTextViewManager(), + SelectableTextViewManager(), + ReactViewManager(), + ReactVirtualViewManager(), + ReactUnimplementedViewManager(), + ) /** * A map of view managers that should be registered with @@ -167,41 +166,46 @@ constructor(private val config: MainPackageConfig? = null) : */ @Suppress("DEPRECATION") @SuppressLint("VisibleForTests") - public val viewManagersMap: Map = mapOf( - ReactDrawerLayoutManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { ReactDrawerLayoutManager() }, - ReactHorizontalScrollViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { ReactHorizontalScrollViewManager() }, - ReactHorizontalScrollContainerViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { ReactHorizontalScrollContainerViewManager() }, - ReactProgressBarViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { ReactProgressBarViewManager() }, - ReactSafeAreaViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { ReactSafeAreaViewManager() }, - ReactScrollViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { - if (ReactNativeFeatureFlags.useNestedScrollViewAndroid()) ReactNestedScrollViewManager() - else ReactScrollViewManager() - }, - ReactSwitchManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactSwitchManager() }, - SwipeRefreshLayoutManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { SwipeRefreshLayoutManager() }, - ReactImageManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactImageManager() }, - ReactModalHostManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactModalHostManager() }, - ReactTextInputManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactTextInputManager() }, - ReactTextViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { - if (ReactNativeFeatureFlags.enablePreparedTextLayout()) PreparedLayoutTextViewManager() - else ReactTextViewManager() - }, - SelectableTextViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { SelectableTextViewManager() }, - ReactViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactViewManager() }, - ReactVirtualViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { ReactVirtualViewManager() }, - ReactUnimplementedViewManager.REACT_CLASS to - ModuleSpec.viewManagerSpec { ReactUnimplementedViewManager() }, - ) + public val viewManagersMap: Map = + mapOf( + ReactDrawerLayoutManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactDrawerLayoutManager() }, + ReactHorizontalScrollViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactHorizontalScrollViewManager() }, + ReactHorizontalScrollContainerViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactHorizontalScrollContainerViewManager() }, + ReactProgressBarViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactProgressBarViewManager() }, + ReactSafeAreaViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactSafeAreaViewManager() }, + ReactScrollViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { + if (ReactNativeFeatureFlags.useNestedScrollViewAndroid()) + ReactNestedScrollViewManager() + else ReactScrollViewManager() + }, + ReactSwitchManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactSwitchManager() }, + SwipeRefreshLayoutManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { SwipeRefreshLayoutManager() }, + ReactImageManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactImageManager() }, + ReactModalHostManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactModalHostManager() }, + ReactTextInputManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactTextInputManager() }, + ReactTextViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { + if (ReactNativeFeatureFlags.enablePreparedTextLayout()) + PreparedLayoutTextViewManager() + else ReactTextViewManager() + }, + SelectableTextViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { SelectableTextViewManager() }, + ReactViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactViewManager() }, + ReactVirtualViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactVirtualViewManager() }, + ReactUnimplementedViewManager.REACT_CLASS to + ModuleSpec.viewManagerSpec { ReactUnimplementedViewManager() }, + ) public override fun getViewManagers(reactContext: ReactApplicationContext): List = viewManagersMap.values.toList() @@ -247,35 +251,36 @@ constructor(private val config: MainPackageConfig? = null) : private fun fallbackForMissingClass(): ReactModuleInfoProvider { // In the OSS case, the annotation processor does not run. // We fall back to creating this by hand - val moduleList: Array> = arrayOf( - AccessibilityInfoModule::class.java, - AppearanceModule::class.java, - AppStateModule::class.java, - BlobModule::class.java, - DevLoadingModule::class.java, - FileReaderModule::class.java, - ClipboardModule::class.java, - DialogModule::class.java, - FrescoModule::class.java, - I18nManagerModule::class.java, - ImageLoaderModule::class.java, - ImageStoreManager::class.java, - IntentModule::class.java, - if (ReactNativeFeatureFlags.cxxNativeAnimatedEnabled()) null - else NativeAnimatedModule::class.java, - NetworkingModule::class.java, - PermissionsModule::class.java, - ReactDevToolsSettingsManagerModule::class.java, - ReactDevToolsRuntimeSettingsModule::class.java, - ShareModule::class.java, - StatusBarModule::class.java, - SoundManagerModule::class.java, - ToastModule::class.java, - VibrationModule::class.java, - WebSocketModule::class.java, - ) - .filterNotNull() - .toTypedArray() + val moduleList: Array> = + arrayOf( + AccessibilityInfoModule::class.java, + AppearanceModule::class.java, + AppStateModule::class.java, + BlobModule::class.java, + DevLoadingModule::class.java, + FileReaderModule::class.java, + ClipboardModule::class.java, + DialogModule::class.java, + FrescoModule::class.java, + I18nManagerModule::class.java, + ImageLoaderModule::class.java, + ImageStoreManager::class.java, + IntentModule::class.java, + if (ReactNativeFeatureFlags.cxxNativeAnimatedEnabled()) null + else NativeAnimatedModule::class.java, + NetworkingModule::class.java, + PermissionsModule::class.java, + ReactDevToolsSettingsManagerModule::class.java, + ReactDevToolsRuntimeSettingsModule::class.java, + ShareModule::class.java, + StatusBarModule::class.java, + SoundManagerModule::class.java, + ToastModule::class.java, + VibrationModule::class.java, + WebSocketModule::class.java, + ) + .filterNotNull() + .toTypedArray() val moduleMap = moduleList diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt index 1b8f221c103..5582ad102d8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt @@ -535,12 +535,13 @@ public object BackgroundStyleApplicator { paddingBoxRect.bottom = composite.bounds.bottom - (computedBorderInsets?.bottom?.dpToPx() ?: 0f) if (composite.borderRadius?.hasRoundedBorders() == true) { - val paddingBoxPath = createPaddingBoxPath( - view, - composite, - paddingBoxRect, - computedBorderInsets, - ) + val paddingBoxPath = + createPaddingBoxPath( + view, + composite, + paddingBoxRect, + computedBorderInsets, + ) paddingBoxPath.offset(drawingRect.left.toFloat(), drawingRect.top.toFloat()) // On Android 28 and below, use antialiased clipping with Porter-Duff compositing. On newer @@ -763,38 +764,46 @@ public object BackgroundStyleApplicator { val paddingBoxPath = Path() - val innerTopLeftRadiusX = getInnerBorderRadius( - computedBorderRadius?.topLeft?.horizontal?.dpToPx(), - computedBorderInsets?.left?.dpToPx(), - ) - val innerTopLeftRadiusY = getInnerBorderRadius( - computedBorderRadius?.topLeft?.vertical?.dpToPx(), - computedBorderInsets?.top?.dpToPx(), - ) - val innerTopRightRadiusX = getInnerBorderRadius( - computedBorderRadius?.topRight?.horizontal?.dpToPx(), - computedBorderInsets?.right?.dpToPx(), - ) - val innerTopRightRadiusY = getInnerBorderRadius( - computedBorderRadius?.topRight?.vertical?.dpToPx(), - computedBorderInsets?.top?.dpToPx(), - ) - val innerBottomRightRadiusX = getInnerBorderRadius( - computedBorderRadius?.bottomRight?.horizontal?.dpToPx(), - computedBorderInsets?.right?.dpToPx(), - ) - val innerBottomRightRadiusY = getInnerBorderRadius( - computedBorderRadius?.bottomRight?.vertical?.dpToPx(), - computedBorderInsets?.bottom?.dpToPx(), - ) - val innerBottomLeftRadiusX = getInnerBorderRadius( - computedBorderRadius?.bottomLeft?.horizontal?.dpToPx(), - computedBorderInsets?.left?.dpToPx(), - ) - val innerBottomLeftRadiusY = getInnerBorderRadius( - computedBorderRadius?.bottomLeft?.vertical?.dpToPx(), - computedBorderInsets?.bottom?.dpToPx(), - ) + val innerTopLeftRadiusX = + getInnerBorderRadius( + computedBorderRadius?.topLeft?.horizontal?.dpToPx(), + computedBorderInsets?.left?.dpToPx(), + ) + val innerTopLeftRadiusY = + getInnerBorderRadius( + computedBorderRadius?.topLeft?.vertical?.dpToPx(), + computedBorderInsets?.top?.dpToPx(), + ) + val innerTopRightRadiusX = + getInnerBorderRadius( + computedBorderRadius?.topRight?.horizontal?.dpToPx(), + computedBorderInsets?.right?.dpToPx(), + ) + val innerTopRightRadiusY = + getInnerBorderRadius( + computedBorderRadius?.topRight?.vertical?.dpToPx(), + computedBorderInsets?.top?.dpToPx(), + ) + val innerBottomRightRadiusX = + getInnerBorderRadius( + computedBorderRadius?.bottomRight?.horizontal?.dpToPx(), + computedBorderInsets?.right?.dpToPx(), + ) + val innerBottomRightRadiusY = + getInnerBorderRadius( + computedBorderRadius?.bottomRight?.vertical?.dpToPx(), + computedBorderInsets?.bottom?.dpToPx(), + ) + val innerBottomLeftRadiusX = + getInnerBorderRadius( + computedBorderRadius?.bottomLeft?.horizontal?.dpToPx(), + computedBorderInsets?.left?.dpToPx(), + ) + val innerBottomLeftRadiusY = + getInnerBorderRadius( + computedBorderRadius?.bottomLeft?.vertical?.dpToPx(), + computedBorderInsets?.bottom?.dpToPx(), + ) paddingBoxPath.addRoundRect( paddingBoxRect, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.kt index 8d8574e324f..2f7c853f602 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.kt @@ -334,11 +334,12 @@ public class JSPointerDispatcher(private val rootViewGroup: ViewGroup) { // https://suragch.medium.com/how-touch-events-are-delivered-in-android-eee3b607b038 val isExitFromRoot = isCapture && action == MotionEvent.ACTION_HOVER_EXIT - val eventState = createEventState( - activePointerId, - motionEvent, - clearHitPathForActivePointer = isExitFromRoot, - ) + val eventState = + createEventState( + activePointerId, + motionEvent, + clearHitPathForActivePointer = isExitFromRoot, + ) // Calculate the targetTag, with special handling for when we exit the root view. In that case, // we use the root viewId of the last event @@ -496,12 +497,13 @@ public class JSPointerDispatcher(private val rootViewGroup: ViewGroup) { } // target -> root - val leaveViewTargets = filterByShouldDispatch( - lastHitPath.subList(0, lastHitPath.size - firstDivergentIndexFromBack), - EVENT.LEAVE, - EVENT.LEAVE_CAPTURE, - nonDivergentListeningToLeave, - ) + val leaveViewTargets = + filterByShouldDispatch( + lastHitPath.subList(0, lastHitPath.size - firstDivergentIndexFromBack), + EVENT.LEAVE, + EVENT.LEAVE_CAPTURE, + nonDivergentListeningToLeave, + ) if (leaveViewTargets.isNotEmpty()) { // We want to dispatch from target -> root, so no need to reverse dispatchEventForViewTargets( @@ -523,12 +525,13 @@ public class JSPointerDispatcher(private val rootViewGroup: ViewGroup) { } // target -> root - val enterViewTargets = filterByShouldDispatch( - activeHitPath.subList(0, activeHitPath.size - firstDivergentIndexFromBack), - EVENT.ENTER, - EVENT.ENTER_CAPTURE, - nonDivergentListeningToEnter, - ) + val enterViewTargets = + filterByShouldDispatch( + activeHitPath.subList(0, activeHitPath.size - firstDivergentIndexFromBack), + EVENT.ENTER, + EVENT.ENTER_CAPTURE, + nonDivergentListeningToEnter, + ) if (enterViewTargets.isNotEmpty()) { // We want to iterate these from root -> target so we need to reverse diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.kt index 6adaf26effc..cf67f6beb0c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.kt @@ -664,14 +664,15 @@ public open class LayoutShadowNode : ReactShadowNodeImpl() { return } - val positionSpacingTypes = intArrayOf( - Spacing.START, - Spacing.END, - Spacing.LEFT, - Spacing.RIGHT, - Spacing.TOP, - Spacing.BOTTOM, - ) + val positionSpacingTypes = + intArrayOf( + Spacing.START, + Spacing.END, + Spacing.LEFT, + Spacing.RIGHT, + Spacing.TOP, + Spacing.BOTTOM, + ) val spacingType = maybeTransformLeftRightToStartEnd(positionSpacingTypes[index]) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt index 4f50c5e000f..3c1cbe917d1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt @@ -560,14 +560,15 @@ public open class ReactAccessibilityDelegate( // The View this delegate is attac public companion object { public const val TOP_ACCESSIBILITY_ACTION_EVENT: String = "topAccessibilityAction" - private val actionIdMap = mapOf( - "activate" to AccessibilityActionCompat.ACTION_CLICK.id, - "longpress" to AccessibilityActionCompat.ACTION_LONG_CLICK.id, - "increment" to AccessibilityActionCompat.ACTION_SCROLL_FORWARD.id, - "decrement" to AccessibilityActionCompat.ACTION_SCROLL_BACKWARD.id, - "expand" to AccessibilityActionCompat.ACTION_EXPAND.id, - "collapse" to AccessibilityActionCompat.ACTION_COLLAPSE.id, - ) + private val actionIdMap = + mapOf( + "activate" to AccessibilityActionCompat.ACTION_CLICK.id, + "longpress" to AccessibilityActionCompat.ACTION_LONG_CLICK.id, + "increment" to AccessibilityActionCompat.ACTION_SCROLL_FORWARD.id, + "decrement" to AccessibilityActionCompat.ACTION_SCROLL_BACKWARD.id, + "expand" to AccessibilityActionCompat.ACTION_EXPAND.id, + "collapse" to AccessibilityActionCompat.ACTION_COLLAPSE.id, + ) private const val TAG = "ReactAccessibilityDelegate" private var customActionCounter = 0x3f000000 diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.kt index b3b82ecca05..2439018b76b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.kt @@ -169,20 +169,21 @@ public class Spacing(private val defaultValue: Float, private val spacing: Float /** Spacing type that represents the block start direction (top). E.g. `marginBlockStart`. */ public const val BLOCK_START: Int = 11 - private val flagsMap = intArrayOf( - 1, /*LEFT*/ - 2, /*TOP*/ - 4, /*RIGHT*/ - 8, /*BOTTOM*/ - 16, /*START*/ - 32, /*END*/ - 64, /*HORIZONTAL*/ - 128, /*VERTICAL*/ - 256, /*ALL*/ - 512, /*BLOCK*/ - 1024, /*BLOCK_END*/ - 2048, - ) + private val flagsMap = + intArrayOf( + 1, /*LEFT*/ + 2, /*TOP*/ + 4, /*RIGHT*/ + 8, /*BOTTOM*/ + 16, /*START*/ + 32, /*END*/ + 64, /*HORIZONTAL*/ + 128, /*VERTICAL*/ + 256, /*ALL*/ + 512, /*BLOCK*/ + 1024, /*BLOCK_END*/ + 2048, + ) private fun newFullSpacingArray(): FloatArray { return floatArrayOf( diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt index 3debb1cb10a..b38d417f330 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt @@ -355,23 +355,25 @@ public object TouchTargetHelper { } PointerEvents.BOX_ONLY -> { // This view may be the target, its children don't matter - val targetView = findTouchTargetView( - eventCoords, - view, - EnumSet.of(TouchTargetReturnType.SELF), - pathAccumulator, - ) + val targetView = + findTouchTargetView( + eventCoords, + view, + EnumSet.of(TouchTargetReturnType.SELF), + pathAccumulator, + ) targetView?.let { pathAccumulator?.add(ViewTarget(view.id, view)) } targetView } PointerEvents.BOX_NONE -> { // This view can't be the target, but its children might. - val targetView = findTouchTargetView( - eventCoords, - view, - EnumSet.of(TouchTargetReturnType.CHILD), - pathAccumulator, - ) + val targetView = + findTouchTargetView( + eventCoords, + view, + EnumSet.of(TouchTargetReturnType.CHILD), + pathAccumulator, + ) if (targetView != null) { pathAccumulator?.add(ViewTarget(view.id, view)) @@ -410,12 +412,13 @@ public object TouchTargetHelper { return view } - val result = findTouchTargetView( - eventCoords, - view, - EnumSet.of(TouchTargetReturnType.SELF, TouchTargetReturnType.CHILD), - pathAccumulator, - ) + val result = + findTouchTargetView( + eventCoords, + view, + EnumSet.of(TouchTargetReturnType.SELF, TouchTargetReturnType.CHILD), + pathAccumulator, + ) result?.let { pathAccumulator?.add(ViewTarget(view.id, view)) } result } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt index 6c6dcdfef73..513989a14e9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt @@ -83,11 +83,12 @@ public object TransformHelper { val helperMatrix = helperMatrix.get()!! MatrixMathHelper.resetIdentityMatrix(result) - val offsets = getTranslateForTransformOrigin( - viewWidth, - viewHeight, - transformOrigin, - ) + val offsets = + getTranslateForTransformOrigin( + viewWidth, + viewHeight, + transformOrigin, + ) if (offsets != null) { MatrixMathHelper.resetIdentityMatrix(helperMatrix) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.kt index 082b1d56791..5967be095a7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.kt @@ -14,38 +14,39 @@ import com.facebook.react.uimanager.events.TouchEventType /** Constants exposed to JS from [UIManagerModule]. */ internal object UIManagerModuleConstants { @JvmField - val bubblingEventTypeConstants: Map = mapOf( - "topChange" to - mapOf( - "phasedRegistrationNames" to - mapOf("bubbled" to "onChange", "captured" to "onChangeCapture") - ), - "topSelect" to - mapOf( - "phasedRegistrationNames" to - mapOf("bubbled" to "onSelect", "captured" to "onSelectCapture") - ), - TouchEventType.getJSEventName(TouchEventType.START) to - mapOf( - "phasedRegistrationNames" to - mapOf("bubbled" to "onTouchStart", "captured" to "onTouchStartCapture") - ), - TouchEventType.getJSEventName(TouchEventType.MOVE) to - mapOf( - "phasedRegistrationNames" to - mapOf("bubbled" to "onTouchMove", "captured" to "onTouchMoveCapture") - ), - TouchEventType.getJSEventName(TouchEventType.END) to - mapOf( - "phasedRegistrationNames" to - mapOf("bubbled" to "onTouchEnd", "captured" to "onTouchEndCapture") - ), - TouchEventType.getJSEventName(TouchEventType.CANCEL) to - mapOf( - "phasedRegistrationNames" to - mapOf("bubbled" to "onTouchCancel", "captured" to "onTouchCancelCapture") - ), - ) + val bubblingEventTypeConstants: Map = + mapOf( + "topChange" to + mapOf( + "phasedRegistrationNames" to + mapOf("bubbled" to "onChange", "captured" to "onChangeCapture") + ), + "topSelect" to + mapOf( + "phasedRegistrationNames" to + mapOf("bubbled" to "onSelect", "captured" to "onSelectCapture") + ), + TouchEventType.getJSEventName(TouchEventType.START) to + mapOf( + "phasedRegistrationNames" to + mapOf("bubbled" to "onTouchStart", "captured" to "onTouchStartCapture") + ), + TouchEventType.getJSEventName(TouchEventType.MOVE) to + mapOf( + "phasedRegistrationNames" to + mapOf("bubbled" to "onTouchMove", "captured" to "onTouchMoveCapture") + ), + TouchEventType.getJSEventName(TouchEventType.END) to + mapOf( + "phasedRegistrationNames" to + mapOf("bubbled" to "onTouchEnd", "captured" to "onTouchEndCapture") + ), + TouchEventType.getJSEventName(TouchEventType.CANCEL) to + mapOf( + "phasedRegistrationNames" to + mapOf("bubbled" to "onTouchCancel", "captured" to "onTouchCancelCapture") + ), + ) @JvmField val directEventTypeConstants: Map = run { @@ -70,31 +71,32 @@ internal object UIManagerModuleConstants { } @JvmField - val constants: Map = mapOf( - "UIView" to - mapOf( - "ContentMode" to - mapOf( - "ScaleAspectFit" to ImageView.ScaleType.FIT_CENTER.ordinal, - "ScaleAspectFill" to ImageView.ScaleType.CENTER_CROP.ordinal, - "ScaleAspectCenter" to ImageView.ScaleType.CENTER_INSIDE.ordinal, - ) - ), - "StyleConstants" to - mapOf( - "PointerEventsValues" to - mapOf( - "none" to PointerEvents.NONE.ordinal, - "boxNone" to PointerEvents.BOX_NONE.ordinal, - "boxOnly" to PointerEvents.BOX_ONLY.ordinal, - "unspecified" to PointerEvents.AUTO.ordinal, - ) - ), - "AccessibilityEventTypes" to - mapOf( - "typeWindowStateChanged" to AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, - "typeViewFocused" to AccessibilityEvent.TYPE_VIEW_FOCUSED, - "typeViewClicked" to AccessibilityEvent.TYPE_VIEW_CLICKED, - ), - ) + val constants: Map = + mapOf( + "UIView" to + mapOf( + "ContentMode" to + mapOf( + "ScaleAspectFit" to ImageView.ScaleType.FIT_CENTER.ordinal, + "ScaleAspectFill" to ImageView.ScaleType.CENTER_CROP.ordinal, + "ScaleAspectCenter" to ImageView.ScaleType.CENTER_INSIDE.ordinal, + ) + ), + "StyleConstants" to + mapOf( + "PointerEventsValues" to + mapOf( + "none" to PointerEvents.NONE.ordinal, + "boxNone" to PointerEvents.BOX_NONE.ordinal, + "boxOnly" to PointerEvents.BOX_ONLY.ordinal, + "unspecified" to PointerEvents.AUTO.ordinal, + ) + ), + "AccessibilityEventTypes" to + mapOf( + "typeWindowStateChanged" to AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, + "typeViewFocused" to AccessibilityEvent.TYPE_VIEW_FOCUSED, + "typeViewClicked" to AccessibilityEvent.TYPE_VIEW_CLICKED, + ), + ) } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.kt index 3ead4430977..3039c01cdac 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.kt @@ -41,10 +41,11 @@ internal object UIManagerModuleConstantsHelper { @JvmStatic val defaultExportableEventTypes: Map - get() = mapOf( - BUBBLING_EVENTS_KEY to UIManagerModuleConstants.bubblingEventTypeConstants, - DIRECT_EVENTS_KEY to UIManagerModuleConstants.directEventTypeConstants, - ) + get() = + mapOf( + BUBBLING_EVENTS_KEY to UIManagerModuleConstants.bubblingEventTypeConstants, + DIRECT_EVENTS_KEY to UIManagerModuleConstants.directEventTypeConstants, + ) private fun validateDirectEventNames( viewManagerName: String, @@ -110,13 +111,14 @@ internal object UIManagerModuleConstantsHelper { for (viewManager in viewManagers) { val viewManagerName = viewManager.getName() - val viewManagerConstants: MutableMap<*, *> = createConstantsForViewManager( - viewManager, - null, - null, - allBubblingEventTypes, - allDirectEventTypes, - ) + val viewManagerConstants: MutableMap<*, *> = + createConstantsForViewManager( + viewManager, + null, + null, + allBubblingEventTypes, + allDirectEventTypes, + ) if (!viewManagerConstants.isEmpty()) { constants[viewManagerName] = viewManagerConstants } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.kt index b39a5894a0c..5990dc477ca 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.kt @@ -187,77 +187,80 @@ public object ViewProps { internal const val ON_CLICK: String = "onClick" internal const val ON_CLICK_CAPTURE: String = "onClickCapture" @JvmField - public val BORDER_SPACING_TYPES: IntArray = intArrayOf( - Spacing.ALL, - Spacing.START, - Spacing.END, - Spacing.TOP, - Spacing.BOTTOM, - Spacing.LEFT, - Spacing.RIGHT, - ) + public val BORDER_SPACING_TYPES: IntArray = + intArrayOf( + Spacing.ALL, + Spacing.START, + Spacing.END, + Spacing.TOP, + Spacing.BOTTOM, + Spacing.LEFT, + Spacing.RIGHT, + ) @JvmField - public val PADDING_MARGIN_SPACING_TYPES: IntArray = intArrayOf( - Spacing.ALL, - Spacing.VERTICAL, - Spacing.HORIZONTAL, - Spacing.START, - Spacing.END, - Spacing.TOP, - Spacing.BOTTOM, - Spacing.LEFT, - Spacing.RIGHT, - ) - private val LAYOUT_ONLY_PROPS: HashSet = HashSet( - listOf( - ALIGN_SELF, - ALIGN_ITEMS, - COLLAPSABLE, - FLEX, - FLEX_BASIS, - FLEX_DIRECTION, - FLEX_GROW, - ROW_GAP, - COLUMN_GAP, - GAP, - FLEX_SHRINK, - FLEX_WRAP, - JUSTIFY_CONTENT, - ALIGN_CONTENT, - DISPLAY, /* position */ - POSITION, - RIGHT, - TOP, - BOTTOM, - LEFT, - START, - END, /* dimensions */ - WIDTH, - HEIGHT, - MIN_WIDTH, - MAX_WIDTH, - MIN_HEIGHT, - MAX_HEIGHT, /* margins */ - MARGIN, - MARGIN_VERTICAL, - MARGIN_HORIZONTAL, - MARGIN_LEFT, - MARGIN_RIGHT, - MARGIN_TOP, - MARGIN_BOTTOM, - MARGIN_START, - MARGIN_END, /* paddings */ - PADDING, - PADDING_VERTICAL, - PADDING_HORIZONTAL, - PADDING_LEFT, - PADDING_RIGHT, - PADDING_TOP, - PADDING_BOTTOM, - PADDING_START, - PADDING_END, + public val PADDING_MARGIN_SPACING_TYPES: IntArray = + intArrayOf( + Spacing.ALL, + Spacing.VERTICAL, + Spacing.HORIZONTAL, + Spacing.START, + Spacing.END, + Spacing.TOP, + Spacing.BOTTOM, + Spacing.LEFT, + Spacing.RIGHT, + ) + private val LAYOUT_ONLY_PROPS: HashSet = + HashSet( + listOf( + ALIGN_SELF, + ALIGN_ITEMS, + COLLAPSABLE, + FLEX, + FLEX_BASIS, + FLEX_DIRECTION, + FLEX_GROW, + ROW_GAP, + COLUMN_GAP, + GAP, + FLEX_SHRINK, + FLEX_WRAP, + JUSTIFY_CONTENT, + ALIGN_CONTENT, + DISPLAY, /* position */ + POSITION, + RIGHT, + TOP, + BOTTOM, + LEFT, + START, + END, /* dimensions */ + WIDTH, + HEIGHT, + MIN_WIDTH, + MAX_WIDTH, + MIN_HEIGHT, + MAX_HEIGHT, /* margins */ + MARGIN, + MARGIN_VERTICAL, + MARGIN_HORIZONTAL, + MARGIN_LEFT, + MARGIN_RIGHT, + MARGIN_TOP, + MARGIN_BOTTOM, + MARGIN_START, + MARGIN_END, /* paddings */ + PADDING, + PADDING_VERTICAL, + PADDING_HORIZONTAL, + PADDING_LEFT, + PADDING_RIGHT, + PADDING_TOP, + PADDING_BOTTOM, + PADDING_START, + PADDING_END, + ) ) - ) @JvmStatic public fun isLayoutOnly(map: ReadableMap, prop: String): Boolean { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BorderDrawable.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BorderDrawable.kt index 60b4e1cc9cd..d1293ee48d9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BorderDrawable.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BorderDrawable.kt @@ -137,24 +137,26 @@ internal class BorderDrawable( @Deprecated("Deprecated in Java") override fun getOpacity(): Int { - val maxBorderAlpha = maxOf( - (Color.alpha(multiplyColorAlpha(computedBorderColors.left, borderAlpha))), - (Color.alpha(multiplyColorAlpha(computedBorderColors.top, borderAlpha))), - (Color.alpha(multiplyColorAlpha(computedBorderColors.right, borderAlpha))), - (Color.alpha(multiplyColorAlpha(computedBorderColors.bottom, borderAlpha))), - ) + val maxBorderAlpha = + maxOf( + (Color.alpha(multiplyColorAlpha(computedBorderColors.left, borderAlpha))), + (Color.alpha(multiplyColorAlpha(computedBorderColors.top, borderAlpha))), + (Color.alpha(multiplyColorAlpha(computedBorderColors.right, borderAlpha))), + (Color.alpha(multiplyColorAlpha(computedBorderColors.bottom, borderAlpha))), + ) // If the highest alpha value of all border edges is 0, then the drawable is TRANSPARENT. if (maxBorderAlpha == 0) { return PixelFormat.TRANSPARENT } - val minBorderAlpha = minOf( - (Color.alpha(multiplyColorAlpha(computedBorderColors.left, borderAlpha))), - (Color.alpha(multiplyColorAlpha(computedBorderColors.top, borderAlpha))), - (Color.alpha(multiplyColorAlpha(computedBorderColors.right, borderAlpha))), - (Color.alpha(multiplyColorAlpha(computedBorderColors.bottom, borderAlpha))), - ) + val minBorderAlpha = + minOf( + (Color.alpha(multiplyColorAlpha(computedBorderColors.left, borderAlpha))), + (Color.alpha(multiplyColorAlpha(computedBorderColors.top, borderAlpha))), + (Color.alpha(multiplyColorAlpha(computedBorderColors.right, borderAlpha))), + (Color.alpha(multiplyColorAlpha(computedBorderColors.bottom, borderAlpha))), + ) /* * If the lowest alpha value of all border edges is 255, then the drawable is OPAQUE. @@ -241,16 +243,17 @@ internal class BorderDrawable( val top = bounds.top // Check for fast path to border drawing. - val fastBorderColor = fastBorderCompatibleColorOrZero( - borderLeft, - borderTop, - borderRight, - borderBottom, - computedBorderColors.left, - computedBorderColors.top, - computedBorderColors.right, - computedBorderColors.bottom, - ) + val fastBorderColor = + fastBorderCompatibleColorOrZero( + borderLeft, + borderTop, + borderRight, + borderBottom, + computedBorderColors.left, + computedBorderColors.top, + computedBorderColors.right, + computedBorderColors.bottom, + ) if (fastBorderColor != 0) { if (Color.alpha(fastBorderColor) != 0) { // Border color is not transparent. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt index 06a4fa56d64..8e38a8d0ac5 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt @@ -85,12 +85,13 @@ internal class InsetBoxShadowDrawable( val computedBorderRadii = computeBorderRadii() val computedBorderInsets = computeBorderInsets() - val paddingBoxRect = RectF( - bounds.left + (computedBorderInsets?.left ?: 0f), - bounds.top + (computedBorderInsets?.top ?: 0f), - bounds.right - (computedBorderInsets?.right ?: 0f), - bounds.bottom - (computedBorderInsets?.bottom ?: 0f), - ) + val paddingBoxRect = + RectF( + bounds.left + (computedBorderInsets?.left ?: 0f), + bounds.top + (computedBorderInsets?.top ?: 0f), + bounds.right - (computedBorderInsets?.right ?: 0f), + bounds.bottom - (computedBorderInsets?.bottom ?: 0f), + ) val paddingBoxRadii = computedBorderRadii?.let { floatArrayOf( innerRadius(it.topLeft.horizontal, computedBorderInsets?.left), diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/RadialGradient.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/RadialGradient.kt index 8f48ed0a04b..deaceccc87f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/RadialGradient.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/RadialGradient.kt @@ -327,12 +327,13 @@ internal class RadialGradient( height: Float, sizeKeyword: GradientSize.KeywordType, ): Pair { - val corners = arrayOf( - Pair(0f, 0f), // top-left - Pair(width, 0f), // top-right - Pair(width, height), // bottom-right - Pair(0f, height), // bottom-left - ) + val corners = + arrayOf( + Pair(0f, 0f), // top-left + Pair(width, 0f), // top-right + Pair(width, height), // bottom-right + Pair(0f, height), // bottom-left + ) var cornerIndex = 0 var distance = diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.kt index 71eda73fe5b..c650fda90f0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.kt @@ -150,10 +150,11 @@ public class ReactDrawerLayoutManager : return true } - public override fun getCommandsMap(): Map = mapOf( - COMMAND_OPEN_DRAWER to OPEN_DRAWER, - COMMAND_CLOSE_DRAWER to CLOSE_DRAWER, - ) + public override fun getCommandsMap(): Map = + mapOf( + COMMAND_OPEN_DRAWER to OPEN_DRAWER, + COMMAND_CLOSE_DRAWER to CLOSE_DRAWER, + ) @Deprecated( message = diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt index fa01aecb789..1e912671068 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt @@ -290,13 +290,14 @@ public class ReactImageView( for (idx in 0 until sources.size()) { val source = sources.getMap(idx) ?: continue val cacheControl = computeCacheControl(source.getString("cache")) - var imageSource = ImageSource( - context, - source.getString("uri"), - source.getDouble("width"), - source.getDouble("height"), - cacheControl, - ) + var imageSource = + ImageSource( + context, + source.getString("uri"), + source.getDouble("width"), + source.getDouble("height"), + cacheControl, + ) if (Uri.EMPTY == imageSource.uri) { warnImageSource(source.getString("uri")) imageSource = getTransparentBitmapImageSource(context) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollView.kt index d4db73d704b..fb83f06a993 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollView.kt @@ -8,11 +8,9 @@ */ /** - * THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY - * Source: ReactScrollView.kt - * Run: node generate-nested-scroll-view.js + * THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY Source: ReactScrollView.kt Run: node + * generate-nested-scroll-view.js */ - package com.facebook.react.views.scroll import android.animation.ObjectAnimator @@ -30,8 +28,8 @@ import android.view.View import android.view.ViewGroup import android.view.accessibility.AccessibilityNodeInfo import android.widget.OverScroller -import androidx.core.widget.NestedScrollView import androidx.core.view.ViewCompat +import androidx.core.widget.NestedScrollView import com.facebook.common.logging.FLog import com.facebook.react.R import com.facebook.react.bridge.ReadableMap @@ -75,8 +73,8 @@ import kotlin.math.round import kotlin.math.sign /** - * A simple subclass of NestedScrollView that doesn't dispatch measure and layout to its children and has - * a scroll listener to send scroll events to JS. + * A simple subclass of NestedScrollView that doesn't dispatch measure and layout to its children + * and has a scroll listener to send scroll events to JS. * * ReactNestedScrollView only supports vertical scrolling. For horizontal scrolling, use * [ReactHorizontalScrollView]. @@ -478,11 +476,11 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) : } /** - * Since ReactNestedScrollView handles layout changes on JS side, it does not call super.onLayout due to - * which mIsLayoutDirty flag in NestedScrollView remains true and prevents scrolling to child when - * requestChildFocus is called. Overriding this method and scrolling to child without checking any - * layout dirty flag. This will fix focus navigation issue for KeyEvents which are not handled by - * NestedScrollView, for example: KEYCODE_TAB. + * Since ReactNestedScrollView handles layout changes on JS side, it does not call super.onLayout + * due to which mIsLayoutDirty flag in NestedScrollView remains true and prevents scrolling to + * child when requestChildFocus is called. Overriding this method and scrolling to child without + * checking any layout dirty flag. This will fix focus navigation issue for KeyEvents which are + * not handled by NestedScrollView, for example: KEYCODE_TAB. */ override fun requestChildFocus(child: View, focused: View?) { if (focused != null && scrollsChildToFocus) { @@ -492,9 +490,9 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) : } /** - * In rare cases where an app overrides the built-in ReactNestedScrollView by overriding it, and also - * needs to customize scroll into view on focus behaviors, this protected method can be used to - * unblocks such customization. + * In rare cases where an app overrides the built-in ReactNestedScrollView by overriding it, and + * also needs to customize scroll into view on focus behaviors, this protected method can be used + * to unblocks such customization. */ protected open fun requestChildFocusWithoutScroll(child: View, focused: View?) { super.requestChildFocus(child, focused) @@ -1261,13 +1259,13 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) : * of the NestedScrollView. Whether or not the navbar is obscuring the React Native surface is * determined outside of React Native. * - * Note: all NestedScrollViews and HorizontalScrollViews in React have exactly one child: the "content" - * View (see NestedScrollView.js). That View is non-collapsable so it will never be View-flattened away. - * However, it is possible to pass custom styles into that View. + * Note: all NestedScrollViews and HorizontalScrollViews in React have exactly one child: the + * "content" View (see NestedScrollView.js). That View is non-collapsable so it will never be + * View-flattened away. However, it is possible to pass custom styles into that View. * - * If you are using this feature it is assumed that you have full control over this NestedScrollView and - * that you are **not** overriding the NestedScrollView content view to pass in a `translateY` style. - * `translateY` must never be set from ReactJS while using this feature! + * If you are using this feature it is assumed that you have full control over this + * NestedScrollView and that you are **not** overriding the NestedScrollView content view to pass + * in a `translateY` style. `translateY` must never be set from ReactJS while using this feature! */ public open fun setScrollAwayPaddingEnabledUnstable(topPadding: Int, bottomPadding: Int) { setScrollAwayPaddingEnabledUnstable(topPadding, bottomPadding, true) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollViewManager.kt index 09e25e2d624..d066ed5c9da 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollViewManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollViewManager.kt @@ -8,11 +8,9 @@ */ /** - * THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY - * Source: ReactScrollViewManager.kt - * Run: node generate-nested-scroll-view.js + * THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY Source: ReactScrollViewManager.kt Run: node + * generate-nested-scroll-view.js */ - package com.facebook.react.views.scroll import android.graphics.Color @@ -108,7 +106,10 @@ constructor(private val fpsListener: FpsListener? = null) : } @ReactProp(name = "disableIntervalMomentum") - public fun setDisableIntervalMomentum(view: ReactNestedScrollView, disableIntervalMomentum: Boolean) { + public fun setDisableIntervalMomentum( + view: ReactNestedScrollView, + disableIntervalMomentum: Boolean, + ) { view.setDisableIntervalMomentum(disableIntervalMomentum) } @@ -221,7 +222,11 @@ constructor(private val fpsListener: FpsListener? = null) : "ReceiveCommand with an int commandId param is deprecated. Use the overload where commandId is a string.", ReplaceWith("receiveCommand(scrollView, commandId, args)"), ) - override fun receiveCommand(scrollView: ReactNestedScrollView, commandId: Int, args: ReadableArray?) { + override fun receiveCommand( + scrollView: ReactNestedScrollView, + commandId: Int, + args: ReadableArray?, + ) { receiveCommand(this, scrollView, commandId, args) } @@ -450,15 +455,17 @@ constructor(private val fpsListener: FpsListener? = null) : public companion object { public const val REACT_CLASS: String = "RCTScrollView" - public fun createExportedCustomDirectEventTypeConstants(): Map = mapOf( - getJSEventName(ScrollEventType.SCROLL) to mapOf("registrationName" to "onScroll"), - getJSEventName(ScrollEventType.BEGIN_DRAG) to - mapOf("registrationName" to "onScrollBeginDrag"), - getJSEventName(ScrollEventType.END_DRAG) to mapOf("registrationName" to "onScrollEndDrag"), - getJSEventName(ScrollEventType.MOMENTUM_BEGIN) to - mapOf("registrationName" to "onMomentumScrollBegin"), - getJSEventName(ScrollEventType.MOMENTUM_END) to - mapOf("registrationName" to "onMomentumScrollEnd"), - ) + public fun createExportedCustomDirectEventTypeConstants(): Map = + mapOf( + getJSEventName(ScrollEventType.SCROLL) to mapOf("registrationName" to "onScroll"), + getJSEventName(ScrollEventType.BEGIN_DRAG) to + mapOf("registrationName" to "onScrollBeginDrag"), + getJSEventName(ScrollEventType.END_DRAG) to + mapOf("registrationName" to "onScrollEndDrag"), + getJSEventName(ScrollEventType.MOMENTUM_BEGIN) to + mapOf("registrationName" to "onMomentumScrollBegin"), + getJSEventName(ScrollEventType.MOMENTUM_END) to + mapOf("registrationName" to "onMomentumScrollEnd"), + ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.kt index 3bdff097b4b..a922cdbfd6f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewCommandHelper.kt @@ -18,11 +18,12 @@ public class ReactScrollViewCommandHelper { public const val COMMAND_FLASH_SCROLL_INDICATORS: Int = 3 @JvmStatic - public fun getCommandsMap(): Map = hashMapOf( - "scrollTo" to COMMAND_SCROLL_TO, - "scrollToEnd" to COMMAND_SCROLL_TO_END, - "flashScrollIndicators" to COMMAND_FLASH_SCROLL_INDICATORS, - ) + public fun getCommandsMap(): Map = + hashMapOf( + "scrollTo" to COMMAND_SCROLL_TO, + "scrollToEnd" to COMMAND_SCROLL_TO_END, + "flashScrollIndicators" to COMMAND_FLASH_SCROLL_INDICATORS, + ) @JvmStatic public fun receiveCommand( diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt index 7094127e6d9..f96baf0200d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt @@ -442,15 +442,17 @@ constructor(private val fpsListener: FpsListener? = null) : public companion object { public const val REACT_CLASS: String = "RCTScrollView" - public fun createExportedCustomDirectEventTypeConstants(): Map = mapOf( - getJSEventName(ScrollEventType.SCROLL) to mapOf("registrationName" to "onScroll"), - getJSEventName(ScrollEventType.BEGIN_DRAG) to - mapOf("registrationName" to "onScrollBeginDrag"), - getJSEventName(ScrollEventType.END_DRAG) to mapOf("registrationName" to "onScrollEndDrag"), - getJSEventName(ScrollEventType.MOMENTUM_BEGIN) to - mapOf("registrationName" to "onMomentumScrollBegin"), - getJSEventName(ScrollEventType.MOMENTUM_END) to - mapOf("registrationName" to "onMomentumScrollEnd"), - ) + public fun createExportedCustomDirectEventTypeConstants(): Map = + mapOf( + getJSEventName(ScrollEventType.SCROLL) to mapOf("registrationName" to "onScroll"), + getJSEventName(ScrollEventType.BEGIN_DRAG) to + mapOf("registrationName" to "onScrollBeginDrag"), + getJSEventName(ScrollEventType.END_DRAG) to + mapOf("registrationName" to "onScrollEndDrag"), + getJSEventName(ScrollEventType.MOMENTUM_BEGIN) to + mapOf("registrationName" to "onMomentumScrollBegin"), + getJSEventName(ScrollEventType.MOMENTUM_END) to + mapOf("registrationName" to "onMomentumScrollEnd"), + ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.kt index c105abedbfa..e7bcd77cc30 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.kt @@ -170,18 +170,19 @@ public class ScrollEvent private constructor() : Event() { contentHeight: Int, scrollViewWidth: Int, scrollViewHeight: Int, - ): ScrollEvent = obtain( - ViewUtil.NO_SURFACE_ID, - viewTag, - scrollEventType, - scrollX, - scrollY, - xVelocity, - yVelocity, - contentWidth, - contentHeight, - scrollViewWidth, - scrollViewHeight, - ) + ): ScrollEvent = + obtain( + ViewUtil.NO_SURFACE_ID, + viewTag, + scrollEventType, + scrollX, + scrollY, + xVelocity, + yVelocity, + contentWidth, + contentHeight, + scrollViewWidth, + scrollViewHeight, + ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt index 327d2656f64..dad6ce9aa1c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt @@ -25,12 +25,13 @@ internal class ReactTextUpdate( textAlign: Int, textBreakStrategy: Int, justificationMode: Int, - ): ReactTextUpdate = ReactTextUpdate( - text, - jsEventCounter, - textAlign, - textBreakStrategy, - justificationMode, - ) + ): ReactTextUpdate = + ReactTextUpdate( + text, + jsEventCounter, + textAlign, + textBreakStrategy, + justificationMode, + ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt index 31702549913..9fb9553ee63 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt @@ -668,13 +668,14 @@ internal object TextLayoutManager { fontWeightAdjustment: Int, attributedString: MapBuffer, reactTextViewManagerCallback: ReactTextViewManagerCallback?, - ): Spannable = getOrCreateSpannableForText( - assets, - fontWeightAdjustment, - attributedString, - reactTextViewManagerCallback, - null, - ) + ): Spannable = + getOrCreateSpannableForText( + assets, + fontWeightAdjustment, + attributedString, + reactTextViewManagerCallback, + null, + ) @OptIn(UnstableReactNativeAPI::class) internal fun getOrCreateSpannableForText( @@ -682,13 +683,14 @@ internal object TextLayoutManager { attributedString: MapBuffer, reactTextViewManagerCallback: ReactTextViewManagerCallback?, textEffectRegistry: TextEffectRegistry?, - ): Spannable = getOrCreateSpannableForText( - assets, - 0, - attributedString, - reactTextViewManagerCallback, - textEffectRegistry, - ) + ): Spannable = + getOrCreateSpannableForText( + assets, + 0, + attributedString, + reactTextViewManagerCallback, + textEffectRegistry, + ) @OptIn(UnstableReactNativeAPI::class) internal fun getOrCreateSpannableForText( @@ -727,13 +729,14 @@ internal object TextLayoutManager { textEffectRegistry: TextEffectRegistry? = null, ): Spannable { if (ReactNativeFeatureFlags.enableAndroidTextMeasurementOptimizations()) { - val spannable = buildSpannableFromFragmentsOptimized( - assets, - fontWeightAdjustment, - fragments, - outputReactTags, - textEffectRegistry, - ) + val spannable = + buildSpannableFromFragmentsOptimized( + assets, + fontWeightAdjustment, + fragments, + outputReactTags, + textEffectRegistry, + ) reactTextViewManagerCallback?.onPostProcessSpannable(spannable) return spannable @@ -955,13 +958,14 @@ internal object TextLayoutManager { reactTextViewManagerCallback: ReactTextViewManagerCallback?, textEffectRegistry: TextEffectRegistry? = null, ): Layout { - val text = getOrCreateSpannableForText( - assets, - fontWeightAdjustment, - attributedString, - reactTextViewManagerCallback, - textEffectRegistry, - ) + val text = + getOrCreateSpannableForText( + assets, + fontWeightAdjustment, + attributedString, + reactTextViewManagerCallback, + textEffectRegistry, + ) val paint: TextPaint if (attributedString.contains(AS_KEY_CACHE_ID)) { @@ -973,15 +977,15 @@ internal object TextLayoutManager { } return createLayout( - text, - paint, - attributedString, - paragraphAttributes, - width, - widthYogaMeasureMode, - height, - heightYogaMeasureMode, - ) + text, + paint, + attributedString, + paragraphAttributes, + width, + widthYogaMeasureMode, + height, + heightYogaMeasureMode, + ) .layout } @@ -1084,18 +1088,19 @@ internal object TextLayoutManager { heightYogaMeasureMode: YogaMeasureMode, reactTextViewManagerCallback: ReactTextViewManagerCallback?, textEffectRegistry: TextEffectRegistry? = null, - ): PreparedLayout = createPreparedLayout( - assets, - 0, - attributedString, - paragraphAttributes, - width, - widthYogaMeasureMode, - height, - heightYogaMeasureMode, - reactTextViewManagerCallback, - textEffectRegistry, - ) + ): PreparedLayout = + createPreparedLayout( + assets, + 0, + attributedString, + paragraphAttributes, + width, + widthYogaMeasureMode, + height, + heightYogaMeasureMode, + reactTextViewManagerCallback, + textEffectRegistry, + ) @JvmStatic @OptIn(UnstableReactNativeAPI::class) @@ -1113,39 +1118,42 @@ internal object TextLayoutManager { ): PreparedLayout { val fragments = attributedString.getMapBuffer(AS_KEY_FRAGMENTS) val reactTags = IntArray(fragments.count) - val text = createSpannableFromAttributedString( - assets, - fontWeightAdjustment, - fragments, - reactTextViewManagerCallback, - reactTags, - textEffectRegistry, - ) + val text = + createSpannableFromAttributedString( + assets, + fontWeightAdjustment, + fragments, + reactTextViewManagerCallback, + reactTags, + textEffectRegistry, + ) val baseTextAttributes = TextAttributeProps.fromMapBuffer(attributedString.getMapBuffer(AS_KEY_BASE_ATTRIBUTES)) - val result = createLayout( - text, - newPaintWithAttributes(baseTextAttributes, assets, fontWeightAdjustment), - attributedString, - paragraphAttributes, - width, - widthYogaMeasureMode, - height, - heightYogaMeasureMode, - ) + val result = + createLayout( + text, + newPaintWithAttributes(baseTextAttributes, assets, fontWeightAdjustment), + attributedString, + paragraphAttributes, + width, + widthYogaMeasureMode, + height, + heightYogaMeasureMode, + ) val maximumNumberOfLines = if (paragraphAttributes.contains(PA_KEY_MAX_NUMBER_OF_LINES)) paragraphAttributes.getInt(PA_KEY_MAX_NUMBER_OF_LINES) else ReactConstants.UNSET - val verticalOffset = getVerticalOffset( - result.layout, - paragraphAttributes, - height, - heightYogaMeasureMode, - maximumNumberOfLines, - ) + val verticalOffset = + getVerticalOffset( + result.layout, + paragraphAttributes, + height, + heightYogaMeasureMode, + maximumNumberOfLines, + ) return PreparedLayout( result.layout, @@ -1275,19 +1283,20 @@ internal object TextLayoutManager { reactTextViewManagerCallback: ReactTextViewManagerCallback?, attachmentsPositions: FloatArray?, textEffectRegistry: TextEffectRegistry? = null, - ): Long = measureText( - assets, - 0, - attributedString, - paragraphAttributes, - width, - widthYogaMeasureMode, - height, - heightYogaMeasureMode, - reactTextViewManagerCallback, - attachmentsPositions, - textEffectRegistry, - ) + ): Long = + measureText( + assets, + 0, + attributedString, + paragraphAttributes, + width, + widthYogaMeasureMode, + height, + heightYogaMeasureMode, + reactTextViewManagerCallback, + attachmentsPositions, + textEffectRegistry, + ) @JvmStatic @OptIn(UnstableReactNativeAPI::class) @@ -1305,18 +1314,19 @@ internal object TextLayoutManager { textEffectRegistry: TextEffectRegistry? = null, ): Long { // TODO(5578671): Handle text direction (see View#getTextDirectionHeuristic) - val layout = createLayoutForMeasurement( - assets, - fontWeightAdjustment, - attributedString, - paragraphAttributes, - width, - widthYogaMeasureMode, - height, - heightYogaMeasureMode, - reactTextViewManagerCallback, - textEffectRegistry, - ) + val layout = + createLayoutForMeasurement( + assets, + fontWeightAdjustment, + attributedString, + paragraphAttributes, + width, + widthYogaMeasureMode, + height, + heightYogaMeasureMode, + reactTextViewManagerCallback, + textEffectRegistry, + ) val maximumNumberOfLines = if (paragraphAttributes.contains(PA_KEY_MAX_NUMBER_OF_LINES)) @@ -1573,16 +1583,17 @@ internal object TextLayoutManager { height: Float, reactTextViewManagerCallback: ReactTextViewManagerCallback?, textEffectRegistry: TextEffectRegistry? = null, - ): WritableArray = measureLines( - assetManager, - 0, - attributedString, - paragraphAttributes, - width, - height, - reactTextViewManagerCallback, - textEffectRegistry, - ) + ): WritableArray = + measureLines( + assetManager, + 0, + attributedString, + paragraphAttributes, + width, + height, + reactTextViewManagerCallback, + textEffectRegistry, + ) @JvmStatic @OptIn(UnstableReactNativeAPI::class) @@ -1596,18 +1607,19 @@ internal object TextLayoutManager { reactTextViewManagerCallback: ReactTextViewManagerCallback?, textEffectRegistry: TextEffectRegistry? = null, ): WritableArray { - val layout = createLayoutForMeasurement( - assetManager, - fontWeightAdjustment, - attributedString, - paragraphAttributes, - width, - YogaMeasureMode.EXACTLY, - height, - YogaMeasureMode.EXACTLY, - reactTextViewManagerCallback, - textEffectRegistry, - ) + val layout = + createLayoutForMeasurement( + assetManager, + fontWeightAdjustment, + attributedString, + paragraphAttributes, + width, + YogaMeasureMode.EXACTLY, + height, + YogaMeasureMode.EXACTLY, + reactTextViewManagerCallback, + textEffectRegistry, + ) return FontMetricsUtil.getFontMetrics( layout.text, layout, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt index 736c411c402..d0831460a65 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt @@ -1066,58 +1066,60 @@ public open class ReactTextInputManager public constructor() : // private const val TX_STATE_KEY_HASH: Short = 2 private const val TX_STATE_KEY_MOST_RECENT_EVENT_COUNT: Short = 3 - private val REACT_PROPS_AUTOFILL_HINTS_MAP: Map = mapOf( - "2fa-app-otp" to HintConstants.AUTOFILL_HINT_2FA_APP_OTP, - "birthdate-day" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_DAY, - "birthdate-full" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_FULL, - "birthdate-month" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_MONTH, - "birthdate-year" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_YEAR, - "cc-csc" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, - "cc-exp" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, - "cc-exp-day" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, - "cc-exp-month" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, - "cc-exp-year" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, - "cc-number" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_NUMBER, - "email" to HintConstants.AUTOFILL_HINT_EMAIL_ADDRESS, - "email-otp" to HintConstants.AUTOFILL_HINT_EMAIL_OTP, - "flight-confirmation-code" to HintConstants.AUTOFILL_HINT_FLIGHT_CONFIRMATION_CODE, - "flight-number" to HintConstants.AUTOFILL_HINT_FLIGHT_NUMBER, - "gender" to HintConstants.AUTOFILL_HINT_GENDER, - "gift-card-number" to HintConstants.AUTOFILL_HINT_GIFT_CARD_NUMBER, - "gift-card-pin" to HintConstants.AUTOFILL_HINT_GIFT_CARD_PIN, - "loyalty-account-number" to HintConstants.AUTOFILL_HINT_LOYALTY_ACCOUNT_NUMBER, - "name" to HintConstants.AUTOFILL_HINT_PERSON_NAME, - "name-family" to HintConstants.AUTOFILL_HINT_PERSON_NAME_FAMILY, - "name-given" to HintConstants.AUTOFILL_HINT_PERSON_NAME_GIVEN, - "name-middle" to HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE, - "name-middle-initial" to HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE_INITIAL, - "name-prefix" to HintConstants.AUTOFILL_HINT_PERSON_NAME_PREFIX, - "name-suffix" to HintConstants.AUTOFILL_HINT_PERSON_NAME_SUFFIX, - "password" to HintConstants.AUTOFILL_HINT_PASSWORD, - "password-new" to HintConstants.AUTOFILL_HINT_NEW_PASSWORD, - "postal-address" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS, - "postal-address-country" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_COUNTRY, - "postal-address-dependent-locality" to - HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_DEPENDENT_LOCALITY, - "postal-address-extended" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_ADDRESS, - "postal-address-extended-postal-code" to - HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_POSTAL_CODE, - "postal-address-locality" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_LOCALITY, - "postal-address-region" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_REGION, - "postal-address-unit" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_APT_NUMBER, - "postal-code" to HintConstants.AUTOFILL_HINT_POSTAL_CODE, - "promo-code" to HintConstants.AUTOFILL_HINT_PROMO_CODE, - "street-address" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_STREET_ADDRESS, - "sms-otp" to HintConstants.AUTOFILL_HINT_SMS_OTP, - "tel" to HintConstants.AUTOFILL_HINT_PHONE_NUMBER, - "tel-country-code" to HintConstants.AUTOFILL_HINT_PHONE_COUNTRY_CODE, - "tel-national" to HintConstants.AUTOFILL_HINT_PHONE_NATIONAL, - "tel-device" to HintConstants.AUTOFILL_HINT_PHONE_NUMBER_DEVICE, - "upi-vpa" to HintConstants.AUTOFILL_HINT_UPI_VPA, - "wifi-password" to HintConstants.AUTOFILL_HINT_WIFI_PASSWORD, - "username" to HintConstants.AUTOFILL_HINT_USERNAME, - "username-new" to HintConstants.AUTOFILL_HINT_NEW_USERNAME, - ) + private val REACT_PROPS_AUTOFILL_HINTS_MAP: Map = + mapOf( + "2fa-app-otp" to HintConstants.AUTOFILL_HINT_2FA_APP_OTP, + "birthdate-day" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_DAY, + "birthdate-full" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_FULL, + "birthdate-month" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_MONTH, + "birthdate-year" to HintConstants.AUTOFILL_HINT_BIRTH_DATE_YEAR, + "cc-csc" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, + "cc-exp" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, + "cc-exp-day" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, + "cc-exp-month" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, + "cc-exp-year" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, + "cc-number" to HintConstants.AUTOFILL_HINT_CREDIT_CARD_NUMBER, + "email" to HintConstants.AUTOFILL_HINT_EMAIL_ADDRESS, + "email-otp" to HintConstants.AUTOFILL_HINT_EMAIL_OTP, + "flight-confirmation-code" to HintConstants.AUTOFILL_HINT_FLIGHT_CONFIRMATION_CODE, + "flight-number" to HintConstants.AUTOFILL_HINT_FLIGHT_NUMBER, + "gender" to HintConstants.AUTOFILL_HINT_GENDER, + "gift-card-number" to HintConstants.AUTOFILL_HINT_GIFT_CARD_NUMBER, + "gift-card-pin" to HintConstants.AUTOFILL_HINT_GIFT_CARD_PIN, + "loyalty-account-number" to HintConstants.AUTOFILL_HINT_LOYALTY_ACCOUNT_NUMBER, + "name" to HintConstants.AUTOFILL_HINT_PERSON_NAME, + "name-family" to HintConstants.AUTOFILL_HINT_PERSON_NAME_FAMILY, + "name-given" to HintConstants.AUTOFILL_HINT_PERSON_NAME_GIVEN, + "name-middle" to HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE, + "name-middle-initial" to HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE_INITIAL, + "name-prefix" to HintConstants.AUTOFILL_HINT_PERSON_NAME_PREFIX, + "name-suffix" to HintConstants.AUTOFILL_HINT_PERSON_NAME_SUFFIX, + "password" to HintConstants.AUTOFILL_HINT_PASSWORD, + "password-new" to HintConstants.AUTOFILL_HINT_NEW_PASSWORD, + "postal-address" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS, + "postal-address-country" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_COUNTRY, + "postal-address-dependent-locality" to + HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_DEPENDENT_LOCALITY, + "postal-address-extended" to + HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_ADDRESS, + "postal-address-extended-postal-code" to + HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_POSTAL_CODE, + "postal-address-locality" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_LOCALITY, + "postal-address-region" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_REGION, + "postal-address-unit" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_APT_NUMBER, + "postal-code" to HintConstants.AUTOFILL_HINT_POSTAL_CODE, + "promo-code" to HintConstants.AUTOFILL_HINT_PROMO_CODE, + "street-address" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_STREET_ADDRESS, + "sms-otp" to HintConstants.AUTOFILL_HINT_SMS_OTP, + "tel" to HintConstants.AUTOFILL_HINT_PHONE_NUMBER, + "tel-country-code" to HintConstants.AUTOFILL_HINT_PHONE_COUNTRY_CODE, + "tel-national" to HintConstants.AUTOFILL_HINT_PHONE_NATIONAL, + "tel-device" to HintConstants.AUTOFILL_HINT_PHONE_NUMBER_DEVICE, + "upi-vpa" to HintConstants.AUTOFILL_HINT_UPI_VPA, + "wifi-password" to HintConstants.AUTOFILL_HINT_WIFI_PASSWORD, + "username" to HintConstants.AUTOFILL_HINT_USERNAME, + "username-new" to HintConstants.AUTOFILL_HINT_NEW_USERNAME, + ) private const val FOCUS_TEXT_INPUT = 1 private const val BLUR_TEXT_INPUT = 2 diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextScrollWatcher.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextScrollWatcher.kt index 51d082e63ec..7d2dc169064 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextScrollWatcher.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextScrollWatcher.kt @@ -26,19 +26,20 @@ internal class ReactTextScrollWatcher(private val editText: ReactEditText) : Scr override fun onScrollChanged(horiz: Int, vert: Int, oldHoriz: Int, oldVert: Int) { if (previousHorizontal != horiz || previousVert != vert) { - val event = obtain( - surfaceId, - editText.id, - ScrollEventType.SCROLL, - horiz.toFloat(), - vert.toFloat(), - 0f, // can't get x velocity - 0f, // can't get y velocity - 0, // can't get content width - 0, // can't get content height - editText.width, - editText.height, - ) + val event = + obtain( + surfaceId, + editText.id, + ScrollEventType.SCROLL, + horiz.toFloat(), + vert.toFloat(), + 0f, // can't get x velocity + 0f, // can't get y velocity + 0, // can't get content width + 0, // can't get content height + editText.width, + editText.height, + ) eventDispatcher?.dispatchEvent(event) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt index fe3f0b091db..9796d0821b1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt @@ -46,18 +46,19 @@ public open class ReactViewManager : ReactClippingViewManager() public companion object { public const val REACT_CLASS: String = ViewProps.VIEW_CLASS_NAME - private val SPACING_TYPES = intArrayOf( - Spacing.ALL, - Spacing.LEFT, - Spacing.RIGHT, - Spacing.TOP, - Spacing.BOTTOM, - Spacing.START, - Spacing.END, - Spacing.BLOCK, - Spacing.BLOCK_END, - Spacing.BLOCK_START, - ) + private val SPACING_TYPES = + intArrayOf( + Spacing.ALL, + Spacing.LEFT, + Spacing.RIGHT, + Spacing.TOP, + Spacing.BOTTOM, + Spacing.START, + Spacing.END, + Spacing.BLOCK, + Spacing.BLOCK_END, + Spacing.BLOCK_START, + ) private const val CMD_HOTSPOT_UPDATE = 1 private const val CMD_SET_PRESSED = 2 private const val HOTSPOT_UPDATE_KEY = "hotspotUpdate" diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.kt index ecde6d70228..96558a36ee0 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.kt @@ -130,10 +130,11 @@ class NativeAnimatedInterpolationTest { @Test fun testInterpolateString() { val input = doubleArrayOf(0.0, 1.0) - val output = arrayOf( - doubleArrayOf(20.0, 20.0, 20.0, 80.0, 80.0, 80.0, 80.0, 20.0), - doubleArrayOf(40.0, 40.0, 33.0, 60.0, 60.0, 60.0, 65.0, 40.0), - ) + val output = + arrayOf( + doubleArrayOf(20.0, 20.0, 20.0, 80.0, 80.0, 80.0, 80.0, 20.0), + doubleArrayOf(40.0, 40.0, 33.0, 60.0, 60.0, 60.0, 65.0, 40.0), + ) val pattern = "M20,20L20,80L80,80L80,20Z" assertThat( InterpolationAnimatedNode.interpolateString( diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.kt index 3b077075f86..f3d64235274 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.kt @@ -58,17 +58,18 @@ object ReactTestHelper { @OptIn(UnstableReactNativeAPI::class) fun createTestReactApplicationContext(application: Application): ReactApplicationContext { - val reactHost = spy( - ReactHostImpl( - RuntimeEnvironment.getApplication(), - mock(), - mock(), - Task.Companion.IMMEDIATE_EXECUTOR, - Task.Companion.IMMEDIATE_EXECUTOR, - false /* allowPackagerServerAccess */, - false /* useDevSupport */, + val reactHost = + spy( + ReactHostImpl( + RuntimeEnvironment.getApplication(), + mock(), + mock(), + Task.Companion.IMMEDIATE_EXECUTOR, + Task.Companion.IMMEDIATE_EXECUTOR, + false /* allowPackagerServerAccess */, + false /* useDevSupport */, + ) ) - ) return BridgelessReactContext(application, reactHost) } } diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricMountingManagerInstrumentationTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricMountingManagerInstrumentationTest.kt index 0c0e4333f19..1c6951b5922 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricMountingManagerInstrumentationTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricMountingManagerInstrumentationTest.kt @@ -84,15 +84,16 @@ class FabricMountingManagerInstrumentationTest { index: Int, componentName: String = "RCTView", ): IntBufferBatchMountItem { - val intBuffer = intArrayOf( - IntBufferBatchMountItem.INSTRUCTION_CREATE, - reactTag, - 1, - IntBufferBatchMountItem.INSTRUCTION_INSERT, - reactTag, - parentTag, - index, - ) + val intBuffer = + intArrayOf( + IntBufferBatchMountItem.INSTRUCTION_CREATE, + reactTag, + 1, + IntBufferBatchMountItem.INSTRUCTION_INSERT, + reactTag, + parentTag, + index, + ) val objBuffer = arrayOf(componentName, JavaOnlyMap.of(), null, null) return IntBufferBatchMountItem(surfaceId, intBuffer, objBuffer, 1) } @@ -174,21 +175,22 @@ class FabricMountingManagerInstrumentationTest { initialMount.execute(mountingManager) assertThat(smm.getView(42)).isNotNull() - val intBuffer = intArrayOf( - IntBufferBatchMountItem.INSTRUCTION_REMOVE, - 42, - surfaceId, - 0, - IntBufferBatchMountItem.INSTRUCTION_DELETE, - 42, - IntBufferBatchMountItem.INSTRUCTION_CREATE, - 42, - 1, - IntBufferBatchMountItem.INSTRUCTION_INSERT, - 42, - surfaceId, - 0, - ) + val intBuffer = + intArrayOf( + IntBufferBatchMountItem.INSTRUCTION_REMOVE, + 42, + surfaceId, + 0, + IntBufferBatchMountItem.INSTRUCTION_DELETE, + 42, + IntBufferBatchMountItem.INSTRUCTION_CREATE, + 42, + 1, + IntBufferBatchMountItem.INSTRUCTION_INSERT, + 42, + surfaceId, + 0, + ) val objBuffer = arrayOf("RCTView", JavaOnlyMap.of(), null, null) val batchMount = IntBufferBatchMountItem(surfaceId, intBuffer, objBuffer, 2) batchMount.execute(mountingManager) diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt index 00e45c3d92a..ebecb3a9ef9 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt @@ -45,450 +45,462 @@ class TouchEventDispatchTest { private val touchEventCoalescingKeyHelper = TouchEventCoalescingKeyHelper() /** Events (1 pointer): START -> MOVE -> MOVE -> UP */ - private val startMoveEndSequence = listOf( - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_DOWN, - pointerId = 0, - pointerIds = intArrayOf(0), - pointerCoords = arrayOf(pointerCoords(1f, 1f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_MOVE, - pointerId = 0, - pointerIds = intArrayOf(0), - pointerCoords = arrayOf(pointerCoords(1f, 2f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_MOVE, - pointerId = 0, - pointerIds = intArrayOf(0), - pointerCoords = arrayOf(pointerCoords(1f, 3f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_UP, - pointerId = 0, - pointerIds = intArrayOf(0), - pointerCoords = arrayOf(pointerCoords(1f, 3f)), - ), - ) + private val startMoveEndSequence = + listOf( + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_DOWN, + pointerId = 0, + pointerIds = intArrayOf(0), + pointerCoords = arrayOf(pointerCoords(1f, 1f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_MOVE, + pointerId = 0, + pointerIds = intArrayOf(0), + pointerCoords = arrayOf(pointerCoords(1f, 2f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_MOVE, + pointerId = 0, + pointerIds = intArrayOf(0), + pointerCoords = arrayOf(pointerCoords(1f, 3f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_UP, + pointerId = 0, + pointerIds = intArrayOf(0), + pointerCoords = arrayOf(pointerCoords(1f, 3f)), + ), + ) /** Expected values for [startMoveEndSequence] */ - private val startMoveEndExpectedSequence = listOf( - /* - * START event for touch 1: - * { - * touches: [touch1], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 1f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), - ), - /* - * MOVE event for touch 1: - * { - * touches: [touch1], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 2f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), - ), - /* - * MOVE event for touch 1: - * { - * touches: [touch1], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 3f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)), - ), - /* - * END event for touch 1: - * { - * touches: [], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 3f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = emptyList(), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)), - ), - ) + private val startMoveEndExpectedSequence = + listOf( + /* + * START event for touch 1: + * { + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 1f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + ), + /* + * MOVE event for touch 1: + * { + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 2f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), + ), + /* + * MOVE event for touch 1: + * { + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 3f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)), + ), + /* + * END event for touch 1: + * { + * touches: [], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 3f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = emptyList(), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)), + ), + ) /** Events (2 pointer): START 1st -> START 2nd -> MOVE 1st -> UP 2st -> UP 1st */ - private val startPointerMoveUpSequence = listOf( - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_DOWN, - pointerId = 0, - pointerIds = intArrayOf(0), - pointerCoords = arrayOf(pointerCoords(1f, 1f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_POINTER_DOWN, - pointerId = 1, - pointerIds = intArrayOf(0, 1), - pointerCoords = arrayOf(pointerCoords(1f, 1f), pointerCoords(2f, 1f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_MOVE, - pointerId = 0, - pointerIds = intArrayOf(0, 1), - pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_POINTER_UP, - pointerId = 1, - pointerIds = intArrayOf(0, 1), - pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_POINTER_UP, - pointerId = 0, - pointerIds = intArrayOf(0), - pointerCoords = arrayOf(pointerCoords(1f, 2f)), - ), - ) + private val startPointerMoveUpSequence = + listOf( + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_DOWN, + pointerId = 0, + pointerIds = intArrayOf(0), + pointerCoords = arrayOf(pointerCoords(1f, 1f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_POINTER_DOWN, + pointerId = 1, + pointerIds = intArrayOf(0, 1), + pointerCoords = arrayOf(pointerCoords(1f, 1f), pointerCoords(2f, 1f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_MOVE, + pointerId = 0, + pointerIds = intArrayOf(0, 1), + pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_POINTER_UP, + pointerId = 1, + pointerIds = intArrayOf(0, 1), + pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_POINTER_UP, + pointerId = 0, + pointerIds = intArrayOf(0), + pointerCoords = arrayOf(pointerCoords(1f, 2f)), + ), + ) /** Expected values for [startPointerMoveUpSequence] */ - private val startPointerMoveUpExpectedSequence = listOf( - /* - * START event for touch 1: - * { - * touch: 0, - * touches: [touch1], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 1f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), - ), - /* - * START event for touch 2: - * { - * touch: 1, - * touches: [touch0, touch1], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 2f, - locationY = 1f, - time = GESTURE_START_TIME, - pointerId = 1, - touches = - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), - ), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), - ), - /* - * MOVE event for touch 1: - * { - * touch: 0, - * touches: [touch0, touch1], - * changed: [touch0, touch1] - * } - * { - * touch: 1, - * touches: [touch0, touch1], - * changed: [touch0, touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 2f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), - ), - changedTouches = - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), - ), - ), - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 2f, - locationY = 1f, - time = GESTURE_START_TIME, - pointerId = 1, - touches = - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), - ), - changedTouches = - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), - ), - ), - /* - * UP event pointer 1: - * { - * touch: 1, - * touches: [touch0], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 2f, - locationY = 1f, - time = GESTURE_START_TIME, - pointerId = 1, - touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), - ), - /* - * UP event pointer 0: - * { - * touch: 0, - * touches: [], - * changed: [touch0] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 2f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = emptyList(), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), - ), - ) + private val startPointerMoveUpExpectedSequence = + listOf( + /* + * START event for touch 1: + * { + * touch: 0, + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 1f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + ), + /* + * START event for touch 2: + * { + * touch: 1, + * touches: [touch0, touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 2f, + locationY = 1f, + time = GESTURE_START_TIME, + pointerId = 1, + touches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + ), + /* + * MOVE event for touch 1: + * { + * touch: 0, + * touches: [touch0, touch1], + * changed: [touch0, touch1] + * } + * { + * touch: 1, + * touches: [touch0, touch1], + * changed: [touch0, touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 2f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + changedTouches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + ), + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 2f, + locationY = 1f, + time = GESTURE_START_TIME, + pointerId = 1, + touches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + changedTouches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + ), + /* + * UP event pointer 1: + * { + * touch: 1, + * touches: [touch0], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 2f, + locationY = 1f, + time = GESTURE_START_TIME, + pointerId = 1, + touches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + ), + /* + * UP event pointer 0: + * { + * touch: 0, + * touches: [], + * changed: [touch0] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 2f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = emptyList(), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), + ), + ) /** Events (2 pointer): START 1st -> START 2nd -> MOVE 1st -> CANCEL */ - private val startMoveCancelSequence = listOf( - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_DOWN, - pointerId = 0, - pointerIds = intArrayOf(0), - pointerCoords = arrayOf(pointerCoords(1f, 1f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_POINTER_DOWN, - pointerId = 1, - pointerIds = intArrayOf(0, 1), - pointerCoords = arrayOf(pointerCoords(1f, 1f), pointerCoords(2f, 1f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_MOVE, - pointerId = 0, - pointerIds = intArrayOf(0, 1), - pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)), - ), - createTouchEvent( - gestureTime = GESTURE_START_TIME, - action = MotionEvent.ACTION_CANCEL, - pointerId = 0, - pointerIds = intArrayOf(0, 1), - pointerCoords = arrayOf(pointerCoords(1f, 3f), pointerCoords(2f, 1f)), - ), - ) + private val startMoveCancelSequence = + listOf( + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_DOWN, + pointerId = 0, + pointerIds = intArrayOf(0), + pointerCoords = arrayOf(pointerCoords(1f, 1f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_POINTER_DOWN, + pointerId = 1, + pointerIds = intArrayOf(0, 1), + pointerCoords = arrayOf(pointerCoords(1f, 1f), pointerCoords(2f, 1f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_MOVE, + pointerId = 0, + pointerIds = intArrayOf(0, 1), + pointerCoords = arrayOf(pointerCoords(1f, 2f), pointerCoords(2f, 1f)), + ), + createTouchEvent( + gestureTime = GESTURE_START_TIME, + action = MotionEvent.ACTION_CANCEL, + pointerId = 0, + pointerIds = intArrayOf(0, 1), + pointerCoords = arrayOf(pointerCoords(1f, 3f), pointerCoords(2f, 1f)), + ), + ) /** Expected values for [startMoveCancelSequence] */ - private val startMoveCancelExpectedSequence = listOf( - /* - * START event for touch 1: - * { - * touch: 0, - * touches: [touch1], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 1f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), - ), - /* - * START event for touch 2: - * { - * touch: 1, - * touches: [touch0, touch1], - * changed: [touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 2f, - locationY = 1f, - time = GESTURE_START_TIME, - pointerId = 1, - touches = - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), - ), - changedTouches = - listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), - ), - /* - * MOVE event for touch 1: - * { - * touch: 0, - * touches: [touch0, touch1], - * changed: [touch0, touch1] - * } - * { - * touch: 1, - * touches: [touch0, touch1], - * changed: [touch0, touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 2f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = + private val startMoveCancelExpectedSequence = + listOf( + /* + * START event for touch 1: + * { + * touch: 0, + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 1f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + ), + /* + * START event for touch 2: + * { + * touch: 1, + * touches: [touch0, touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 2f, + locationY = 1f, + time = GESTURE_START_TIME, + pointerId = 1, + touches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + changedTouches = + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + ), + /* + * MOVE event for touch 1: + * { + * touch: 0, + * touches: [touch0, touch1], + * changed: [touch0, touch1] + * } + * { + * touch: 1, + * touches: [touch0, touch1], + * changed: [touch0, touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 2f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + changedTouches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + ), + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 2f, + 1f, + GESTURE_START_TIME, + 1, listOf( buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), ), - changedTouches = listOf( buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), ), - ), - buildGestureEvent( - SURFACE_ID, - TARGET_VIEW_ID, - 2f, - 1f, - GESTURE_START_TIME, - 1, - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), ), - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + /* + * CANCEL event: + * { + * touch: 0, + * touches: [], + * changed: [touch0, touch1] + * } + * { + * touch: 1, + * touches: [], + * changed: [touch0, touch1] + * } + */ + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 1f, + locationY = 3f, + time = GESTURE_START_TIME, + pointerId = 0, + touches = emptyList(), + changedTouches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), ), - ), - /* - * CANCEL event: - * { - * touch: 0, - * touches: [], - * changed: [touch0, touch1] - * } - * { - * touch: 1, - * touches: [], - * changed: [touch0, touch1] - * } - */ - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 1f, - locationY = 3f, - time = GESTURE_START_TIME, - pointerId = 0, - touches = emptyList(), - changedTouches = - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), - ), - ), - buildGestureEvent( - surfaceId = SURFACE_ID, - viewTag = TARGET_VIEW_ID, - locationX = 2f, - locationY = 1f, - time = GESTURE_START_TIME, - pointerId = 1, - touches = emptyList(), - changedTouches = - listOf( - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0), - buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), - ), - ), - ) + buildGestureEvent( + surfaceId = SURFACE_ID, + viewTag = TARGET_VIEW_ID, + locationX = 2f, + locationY = 1f, + time = GESTURE_START_TIME, + pointerId = 1, + touches = emptyList(), + changedTouches = + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1), + ), + ), + ) private lateinit var eventDispatcher: EventDispatcher private lateinit var eventEmitter: FabricEventEmitter diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt index 22ffbd76bbb..85576444a54 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt @@ -16,14 +16,15 @@ class ReactModuleInfoTest { @Test fun testCreateReactModuleInfo() { - val reactModuleInfo = ReactModuleInfo( - /* name = */ "name", - /* className = */ "class", - /* canOverrideExistingModule = */ false, - /* needsEagerInit = */ false, - /* isCxxModule = */ false, - /* isTurboModule = */ false, - ) + val reactModuleInfo = + ReactModuleInfo( + /* name = */ "name", + /* className = */ "class", + /* canOverrideExistingModule = */ false, + /* needsEagerInit = */ false, + /* isCxxModule = */ false, + /* isTurboModule = */ false, + ) assertThat(reactModuleInfo.name).isEqualTo("name") assertThat(reactModuleInfo.canOverrideExistingModule).isFalse() assertThat(reactModuleInfo.needsEagerInit).isFalse() diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.kt index b8b6555bd8f..e1d7e99184f 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.kt @@ -219,10 +219,11 @@ class NetworkingModuleTest { @Test fun testHeaders() { - val headers = listOf( - JavaOnlyArray.of("Accept", "text/plain"), - JavaOnlyArray.of("User-Agent", "React test agent/1.0"), - ) + val headers = + listOf( + JavaOnlyArray.of("Accept", "text/plain"), + JavaOnlyArray.of("User-Agent", "React test agent/1.0"), + ) networkingModule.sendRequest( "GET", @@ -364,11 +365,12 @@ class NetworkingModuleTest { @Test fun testMultipartPostRequestHeaders() { setupRequestBodyUtil() - val headers = listOf( - JavaOnlyArray.of("Accept", "text/plain"), - JavaOnlyArray.of("User-Agent", "React test agent/1.0"), - JavaOnlyArray.of("content-type", "multipart/form-data"), - ) + val headers = + listOf( + JavaOnlyArray.of("Accept", "text/plain"), + JavaOnlyArray.of("User-Agent", "React test agent/1.0"), + JavaOnlyArray.of("content-type", "multipart/form-data"), + ) val body = JavaOnlyMap() val formData = JavaOnlyArray() diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt index e3081d5b4d9..f3aefed9303 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt @@ -36,12 +36,13 @@ class ReactHostDelegateTest { Mockito.mock(ReactPackageTurboModuleManagerDelegate.Builder::class.java) val hermesInstance: JSRuntimeFactory = Mockito.mock(HermesInstance::class.java) val jsMainModulePathMocked = "mockedJSMainModulePath" - val delegate = DefaultReactHostDelegate( - jsMainModulePath = jsMainModulePathMocked, - jsBundleLoader = jsBundleLoader, - jsRuntimeFactory = hermesInstance, - turboModuleManagerDelegateBuilder = turboModuleManagerDelegateBuilderMock, - ) + val delegate = + DefaultReactHostDelegate( + jsMainModulePath = jsMainModulePathMocked, + jsBundleLoader = jsBundleLoader, + jsRuntimeFactory = hermesInstance, + turboModuleManagerDelegateBuilder = turboModuleManagerDelegateBuilderMock, + ) assertThat(delegate.jsMainModulePath).isEqualTo(jsMainModulePathMocked) } diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt index 7f15a7fb1c0..4a002f15fb8 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt @@ -28,36 +28,37 @@ class BorderRadiusStyleTest { @Test fun testCorrectPriorityLTR() { - val propertyOrderMap = mapOf( - ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_TOP_LEFT_RADIUS, - BorderRadiusProp.BORDER_TOP_START_RADIUS, - BorderRadiusProp.BORDER_START_START_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS, - BorderRadiusProp.BORDER_TOP_END_RADIUS, - BorderRadiusProp.BORDER_START_END_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_START_RADIUS, - BorderRadiusProp.BORDER_END_START_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_END_RADIUS, - BorderRadiusProp.BORDER_END_END_RADIUS, - ), - ) + val propertyOrderMap = + mapOf( + ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_TOP_LEFT_RADIUS, + BorderRadiusProp.BORDER_TOP_START_RADIUS, + BorderRadiusProp.BORDER_START_START_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS, + BorderRadiusProp.BORDER_TOP_END_RADIUS, + BorderRadiusProp.BORDER_START_END_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_START_RADIUS, + BorderRadiusProp.BORDER_END_START_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_END_RADIUS, + BorderRadiusProp.BORDER_END_END_RADIUS, + ), + ) propertyOrderMap.forEach { order -> val borderRadiusStyle = BorderRadiusStyle() @@ -80,36 +81,37 @@ class BorderRadiusStyleTest { @Test fun testCorrectPriorityRTL() { setContextLeftAndRightSwap(ctx, true) - val propertyOrderMap = mapOf( - ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS, - BorderRadiusProp.BORDER_TOP_END_RADIUS, - BorderRadiusProp.BORDER_START_END_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_TOP_LEFT_RADIUS, - BorderRadiusProp.BORDER_TOP_START_RADIUS, - BorderRadiusProp.BORDER_START_START_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_END_RADIUS, - BorderRadiusProp.BORDER_END_END_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_START_RADIUS, - BorderRadiusProp.BORDER_END_START_RADIUS, - ), - ) + val propertyOrderMap = + mapOf( + ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS, + BorderRadiusProp.BORDER_TOP_END_RADIUS, + BorderRadiusProp.BORDER_START_END_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_TOP_LEFT_RADIUS, + BorderRadiusProp.BORDER_TOP_START_RADIUS, + BorderRadiusProp.BORDER_START_START_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_END_RADIUS, + BorderRadiusProp.BORDER_END_END_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_START_RADIUS, + BorderRadiusProp.BORDER_END_START_RADIUS, + ), + ) propertyOrderMap.forEach { order -> val borderRadiusStyle = BorderRadiusStyle() @@ -127,36 +129,37 @@ class BorderRadiusStyleTest { @Test fun testCorrectPriorityRTLNoSwap() { setContextLeftAndRightSwap(ctx, false) - val propertyOrderMap = mapOf( - ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_TOP_LEFT_RADIUS, - BorderRadiusProp.BORDER_TOP_END_RADIUS, - BorderRadiusProp.BORDER_START_END_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS, - BorderRadiusProp.BORDER_TOP_START_RADIUS, - BorderRadiusProp.BORDER_START_START_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_START_RADIUS, - BorderRadiusProp.BORDER_END_END_RADIUS, - ), - ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to - arrayOf( - BorderRadiusProp.BORDER_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS, - BorderRadiusProp.BORDER_BOTTOM_END_RADIUS, - BorderRadiusProp.BORDER_END_START_RADIUS, - ), - ) + val propertyOrderMap = + mapOf( + ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_LEFT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_TOP_LEFT_RADIUS, + BorderRadiusProp.BORDER_TOP_END_RADIUS, + BorderRadiusProp.BORDER_START_END_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_TOP_RIGHT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS, + BorderRadiusProp.BORDER_TOP_START_RADIUS, + BorderRadiusProp.BORDER_START_START_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_LEFT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_START_RADIUS, + BorderRadiusProp.BORDER_END_END_RADIUS, + ), + ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to + arrayOf( + BorderRadiusProp.BORDER_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS, + BorderRadiusProp.BORDER_BOTTOM_END_RADIUS, + BorderRadiusProp.BORDER_END_START_RADIUS, + ), + ) propertyOrderMap.forEach { order -> val borderRadiusStyle = BorderRadiusStyle() @@ -173,12 +176,13 @@ class BorderRadiusStyleTest { @Test fun testBorderRadiusPercentages() { - val borderRadiusStyle = BorderRadiusStyle( - topLeft = LengthPercentage(0f, LengthPercentageType.PERCENT), - topRight = LengthPercentage(10f, LengthPercentageType.PERCENT), - bottomLeft = LengthPercentage(20f, LengthPercentageType.PERCENT), - bottomRight = LengthPercentage(30f, LengthPercentageType.PERCENT), - ) + val borderRadiusStyle = + BorderRadiusStyle( + topLeft = LengthPercentage(0f, LengthPercentageType.PERCENT), + topRight = LengthPercentage(10f, LengthPercentageType.PERCENT), + bottomLeft = LengthPercentage(20f, LengthPercentageType.PERCENT), + bottomRight = LengthPercentage(30f, LengthPercentageType.PERCENT), + ) val resolved = borderRadiusStyle.resolve(0, context = ctx, width = 1000f, height = 1000f) assertThat(resolved.topLeft).isEqualTo(CornerRadii(0f, 0f)) diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/JSPointerDispatcherTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/JSPointerDispatcherTest.kt index 21041d1c773..63279df820b 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/JSPointerDispatcherTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/JSPointerDispatcherTest.kt @@ -74,11 +74,12 @@ class JSPointerDispatcherTest { @Test fun testPointerEnter() { val childRect = getChildViewRectInRootCoordinates(0) - val ev = createMotionEvent( - MotionEvent.ACTION_DOWN, - childRect.centerX().toFloat(), - childRect.centerY().toFloat(), - ) + val ev = + createMotionEvent( + MotionEvent.ACTION_DOWN, + childRect.centerX().toFloat(), + childRect.centerY().toFloat(), + ) val mockDispatcher: EventDispatcher = mock() pointerDispatcher.handleMotionEvent(ev, mockDispatcher, false) verify(mockDispatcher).dispatchEvent(argThat(EventWithName(PointerEventHelper.POINTER_DOWN))) diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.kt index 969409489e9..27a03f9d12e 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.kt @@ -126,64 +126,67 @@ class MatrixMathHelperTest { @Test fun testMultiplyInto() { - val matrixA = doubleArrayOf( - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0, - 9.0, - 10.0, - 11.0, - 12.0, - 13.0, - 14.0, - 15.0, - 16.0, - ) - val matrixB = doubleArrayOf( - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - ) + val matrixA = + doubleArrayOf( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + ) + val matrixB = + doubleArrayOf( + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + ) val result = DoubleArray(16) MatrixMathHelper.multiplyInto(result, matrixA, matrixB) - val expected = doubleArrayOf( - 2.0, - 4.0, - 6.0, - 8.0, - 10.0, - 12.0, - 14.0, - 16.0, - 18.0, - 20.0, - 22.0, - 24.0, - 26.0, - 28.0, - 30.0, - 32.0, - ) + val expected = + doubleArrayOf( + 2.0, + 4.0, + 6.0, + 8.0, + 10.0, + 12.0, + 14.0, + 16.0, + 18.0, + 20.0, + 22.0, + 24.0, + 26.0, + 28.0, + 30.0, + 32.0, + ) assertThat(result).containsExactly(*expected) } @@ -192,69 +195,72 @@ class MatrixMathHelperTest { fun testCreateIdentityMatrix() { val identity = MatrixMathHelper.createIdentityMatrix() - val expected = doubleArrayOf( - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - ) + val expected = + doubleArrayOf( + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + ) assertThat(identity).containsExactly(*expected) } @Test fun testResetIdentityMatrix() { - val matrix = doubleArrayOf( - 5.0, - 2.0, - 3.0, - 4.0, - 1.0, - 6.0, - 7.0, - 8.0, - 9.0, - 10.0, - 11.0, - 12.0, - 13.0, - 14.0, - 15.0, - 16.0, - ) + val matrix = + doubleArrayOf( + 5.0, + 2.0, + 3.0, + 4.0, + 1.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + ) MatrixMathHelper.resetIdentityMatrix(matrix) - val expected = doubleArrayOf( - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - ) + val expected = + doubleArrayOf( + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + ) assertThat(matrix).containsExactly(*expected) } @@ -264,113 +270,118 @@ class MatrixMathHelperTest { val identityMatrix = MatrixMathHelper.createIdentityMatrix() assertThat(MatrixMathHelper.determinant(identityMatrix)).isEqualTo(1.0) - val matrix = doubleArrayOf( - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - ) + val matrix = + doubleArrayOf( + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + ) assertThat(MatrixMathHelper.determinant(matrix)).isEqualTo(16.0) } @Test fun testInverse() { - val matrix = doubleArrayOf( - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - ) + val matrix = + doubleArrayOf( + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + ) val inverse = MatrixMathHelper.inverse(matrix) - val expected = doubleArrayOf( - 0.5, - 0.0, - 0.0, - 0.0, - 0.0, - 0.5, - 0.0, - 0.0, - 0.0, - 0.0, - 0.5, - 0.0, - 0.0, - 0.0, - 0.0, - 0.5, - ) + val expected = + doubleArrayOf( + 0.5, + 0.0, + 0.0, + 0.0, + 0.0, + 0.5, + 0.0, + 0.0, + 0.0, + 0.0, + 0.5, + 0.0, + 0.0, + 0.0, + 0.0, + 0.5, + ) assertThat(inverse).containsExactly(*expected) } @Test fun testTranspose() { - val matrix = doubleArrayOf( - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0, - 9.0, - 10.0, - 11.0, - 12.0, - 13.0, - 14.0, - 15.0, - 16.0, - ) + val matrix = + doubleArrayOf( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + ) val transposed = MatrixMathHelper.transpose(matrix) - val expected = doubleArrayOf( - 1.0, - 5.0, - 9.0, - 13.0, - 2.0, - 6.0, - 10.0, - 14.0, - 3.0, - 7.0, - 11.0, - 15.0, - 4.0, - 8.0, - 12.0, - 16.0, - ) + val expected = + doubleArrayOf( + 1.0, + 5.0, + 9.0, + 13.0, + 2.0, + 6.0, + 10.0, + 14.0, + 3.0, + 7.0, + 11.0, + 15.0, + 4.0, + 8.0, + 12.0, + 16.0, + ) assertThat(transposed).containsExactly(*expected) } @@ -378,24 +389,25 @@ class MatrixMathHelperTest { @Test fun testMultiplyVectorByMatrix() { val vector = doubleArrayOf(1.0, 2.0, 3.0, 1.0) - val matrix = doubleArrayOf( - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - ) + val matrix = + doubleArrayOf( + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + ) val result = DoubleArray(4) MatrixMathHelper.multiplyVectorByMatrix(vector, matrix, result) diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/style/ColorStopTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/style/ColorStopTest.kt index 005b0bf6d4c..209133c2a04 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/style/ColorStopTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/style/ColorStopTest.kt @@ -30,10 +30,11 @@ class ColorStopTest { @Test fun testBasicColorStops() { - val colorStops = listOf( - ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)), - ColorStop(Color.GREEN, LengthPercentage(42f, LengthPercentageType.PERCENT)), - ) + val colorStops = + listOf( + ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)), + ColorStop(Color.GREEN, LengthPercentage(42f, LengthPercentageType.PERCENT)), + ) val processed = ColorStopUtils.getFixedColorStops(colorStops, 60f) assertThat(processed).hasSize(2) @@ -45,11 +46,12 @@ class ColorStopTest { @Test fun testColorStopsWithFirstAndLastPositionsMissing() { - val colorStops = listOf( - ColorStop(Color.RED), - ColorStop(Color.GREEN, LengthPercentage(30f, LengthPercentageType.PERCENT)), - ColorStop(Color.BLUE), - ) + val colorStops = + listOf( + ColorStop(Color.RED), + ColorStop(Color.GREEN, LengthPercentage(30f, LengthPercentageType.PERCENT)), + ColorStop(Color.BLUE), + ) val processed = ColorStopUtils.getFixedColorStops(colorStops, 80f) assertThat(processed).hasSize(3) @@ -63,13 +65,14 @@ class ColorStopTest { @Test fun testColorStopsWithLessPositionValueThanPreviousPosition() { - val colorStops = listOf( - ColorStop(Color.RED), - ColorStop(Color.GREEN, LengthPercentage(30f, LengthPercentageType.PERCENT)), - ColorStop(Color.BLUE, LengthPercentage(20f, LengthPercentageType.PERCENT)), - ColorStop(Color.GRAY, LengthPercentage(60f, LengthPercentageType.PERCENT)), - ColorStop(Color.CYAN, LengthPercentage(50f, LengthPercentageType.PERCENT)), - ) + val colorStops = + listOf( + ColorStop(Color.RED), + ColorStop(Color.GREEN, LengthPercentage(30f, LengthPercentageType.PERCENT)), + ColorStop(Color.BLUE, LengthPercentage(20f, LengthPercentageType.PERCENT)), + ColorStop(Color.GRAY, LengthPercentage(60f, LengthPercentageType.PERCENT)), + ColorStop(Color.CYAN, LengthPercentage(50f, LengthPercentageType.PERCENT)), + ) val processed = ColorStopUtils.getFixedColorStops(colorStops, 80f) assertThat(processed).hasSize(5) @@ -87,12 +90,13 @@ class ColorStopTest { @Test fun testColorStopsWithMissingMiddlePositions() { - val colorStops = listOf( - ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)), - ColorStop(Color.GREEN), - ColorStop(Color.BLUE), - ColorStop(Color.TRANSPARENT, LengthPercentage(100f, LengthPercentageType.PERCENT)), - ) + val colorStops = + listOf( + ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)), + ColorStop(Color.GREEN), + ColorStop(Color.BLUE), + ColorStop(Color.TRANSPARENT, LengthPercentage(100f, LengthPercentageType.PERCENT)), + ) val processed = ColorStopUtils.getFixedColorStops(colorStops, 100f) assertThat(processed).hasSize(4) @@ -108,10 +112,11 @@ class ColorStopTest { @Test fun testColorStopsWithMixedUnits() { - val colorStops = listOf( - ColorStop(Color.YELLOW, LengthPercentage(100f, LengthPercentageType.POINT)), - ColorStop(Color.BLUE, LengthPercentage(50f, LengthPercentageType.PERCENT)), - ) + val colorStops = + listOf( + ColorStop(Color.YELLOW, LengthPercentage(100f, LengthPercentageType.POINT)), + ColorStop(Color.BLUE, LengthPercentage(50f, LengthPercentageType.PERCENT)), + ) val processed200px = ColorStopUtils.getFixedColorStops(colorStops, 200f) assertThat(processed200px).hasSize(2) @@ -132,13 +137,14 @@ class ColorStopTest { @Test fun testColorStopsWithMultipleTransitionHints() { - val colorStops = listOf( - ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)), - ColorStop(null, LengthPercentage(10f, LengthPercentageType.PERCENT)), - ColorStop(Color.GREEN, LengthPercentage(50f, LengthPercentageType.PERCENT)), - ColorStop(null, LengthPercentage(85f, LengthPercentageType.PERCENT)), - ColorStop(Color.BLUE, LengthPercentage(100f, LengthPercentageType.PERCENT)), - ) + val colorStops = + listOf( + ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)), + ColorStop(null, LengthPercentage(10f, LengthPercentageType.PERCENT)), + ColorStop(Color.GREEN, LengthPercentage(50f, LengthPercentageType.PERCENT)), + ColorStop(null, LengthPercentage(85f, LengthPercentageType.PERCENT)), + ColorStop(Color.BLUE, LengthPercentage(100f, LengthPercentageType.PERCENT)), + ) val processed = ColorStopUtils.getFixedColorStops(colorStops, 100f) assertThat(processed.size).isEqualTo(21) assertThat(processed.first().color).isEqualTo(Color.RED) @@ -155,13 +161,14 @@ class ColorStopTest { @Test fun testColorStopsWithPositionedStopAdjacentToUnpositionedStop() { - val colorStops = listOf( - ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)), - ColorStop(Color.GREEN, LengthPercentage(20f, LengthPercentageType.PERCENT)), - ColorStop(Color.BLUE), - ColorStop(Color.YELLOW, LengthPercentage(80f, LengthPercentageType.PERCENT)), - ColorStop(Color.MAGENTA, LengthPercentage(100f, LengthPercentageType.PERCENT)), - ) + val colorStops = + listOf( + ColorStop(Color.RED, LengthPercentage(0f, LengthPercentageType.PERCENT)), + ColorStop(Color.GREEN, LengthPercentage(20f, LengthPercentageType.PERCENT)), + ColorStop(Color.BLUE), + ColorStop(Color.YELLOW, LengthPercentage(80f, LengthPercentageType.PERCENT)), + ColorStop(Color.MAGENTA, LengthPercentage(100f, LengthPercentageType.PERCENT)), + ) val processed = ColorStopUtils.getFixedColorStops(colorStops, 100f) assertThat(processed).hasSize(5) diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt index f6e38cdcb25..d99a2c8be1c 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt @@ -225,21 +225,22 @@ class ReactTextInputPropertyTest { return } - val expectedHints = listOf( - "2fa-app-otp" to HintConstants.AUTOFILL_HINT_2FA_APP_OTP, - "email-otp" to HintConstants.AUTOFILL_HINT_EMAIL_OTP, - "flight-confirmation-code" to HintConstants.AUTOFILL_HINT_FLIGHT_CONFIRMATION_CODE, - "flight-number" to HintConstants.AUTOFILL_HINT_FLIGHT_NUMBER, - "gift-card-number" to HintConstants.AUTOFILL_HINT_GIFT_CARD_NUMBER, - "gift-card-pin" to HintConstants.AUTOFILL_HINT_GIFT_CARD_PIN, - "loyalty-account-number" to HintConstants.AUTOFILL_HINT_LOYALTY_ACCOUNT_NUMBER, - "postal-address-dependent-locality" to - HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_DEPENDENT_LOCALITY, - "postal-address-unit" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_APT_NUMBER, - "promo-code" to HintConstants.AUTOFILL_HINT_PROMO_CODE, - "upi-vpa" to HintConstants.AUTOFILL_HINT_UPI_VPA, - "wifi-password" to HintConstants.AUTOFILL_HINT_WIFI_PASSWORD, - ) + val expectedHints = + listOf( + "2fa-app-otp" to HintConstants.AUTOFILL_HINT_2FA_APP_OTP, + "email-otp" to HintConstants.AUTOFILL_HINT_EMAIL_OTP, + "flight-confirmation-code" to HintConstants.AUTOFILL_HINT_FLIGHT_CONFIRMATION_CODE, + "flight-number" to HintConstants.AUTOFILL_HINT_FLIGHT_NUMBER, + "gift-card-number" to HintConstants.AUTOFILL_HINT_GIFT_CARD_NUMBER, + "gift-card-pin" to HintConstants.AUTOFILL_HINT_GIFT_CARD_PIN, + "loyalty-account-number" to HintConstants.AUTOFILL_HINT_LOYALTY_ACCOUNT_NUMBER, + "postal-address-dependent-locality" to + HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_DEPENDENT_LOCALITY, + "postal-address-unit" to HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_APT_NUMBER, + "promo-code" to HintConstants.AUTOFILL_HINT_PROMO_CODE, + "upi-vpa" to HintConstants.AUTOFILL_HINT_UPI_VPA, + "wifi-password" to HintConstants.AUTOFILL_HINT_WIFI_PASSWORD, + ) expectedHints.forEach { (autoComplete, expectedHint) -> manager.updateProperties(view, buildStyles("autoComplete", autoComplete)) diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt index 776d86a6d86..0ae099a8f37 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt @@ -67,11 +67,12 @@ internal class RNTesterActivity : ReactActivity() { maybeUpdateBackgroundColor() reactDelegate?.reactHost?.let { reactHost -> - val devMenuConfiguration = DevMenuConfiguration( - devMenuEnabled = true, - shakeGestureEnabled = true, - keyboardShortcutsEnabled = true, - ) + val devMenuConfiguration = + DevMenuConfiguration( + devMenuEnabled = true, + shakeGestureEnabled = true, + keyboardShortcutsEnabled = true, + ) reactHost.setDevMenuConfiguration(devMenuConfiguration) } diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt index 49a940eb729..2a162c4c249 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt @@ -78,21 +78,21 @@ internal class RNTesterApplication : Application(), ReactApplication { ) add( object : ReactPackage, ViewManagerOnDemandReactPackage { - override fun getViewManagerNames( - reactContext: ReactApplicationContext - ) = listOf( - "RNTMyNativeView", - "RNTMyLegacyNativeView", - "RNTReportFullyDrawnView", - ) + override fun getViewManagerNames(reactContext: ReactApplicationContext) = + listOf( + "RNTMyNativeView", + "RNTMyLegacyNativeView", + "RNTReportFullyDrawnView", + ) override fun createViewManagers( reactContext: ReactApplicationContext - ): List> = listOf( - MyNativeViewManager(), - MyLegacyViewManager(reactContext), - ReportFullyDrawnViewManager(), - ) + ): List> = + listOf( + MyNativeViewManager(), + MyLegacyViewManager(reactContext), + ReportFullyDrawnViewManager(), + ) override fun createViewManager( reactContext: ReactApplicationContext, diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt index 82a3916b6e2..9b3e5332522 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt @@ -85,11 +85,12 @@ internal class MyLegacyViewManager(reactContext: ReactApplicationContext) : } } - override fun getCommandsMap(): Map = mapOf( - "changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR, - "addOverlays" to COMMAND_ADD_OVERLAYS, - "removeOverlays" to COMMAND_REMOVE_OVERLAYS, - ) + override fun getCommandsMap(): Map = + mapOf( + "changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR, + "addOverlays" to COMMAND_ADD_OVERLAYS, + "removeOverlays" to COMMAND_REMOVE_OVERLAYS, + ) companion object { const val REACT_CLASS = "RNTMyLegacyNativeView" diff --git a/scripts/lint/clang-format.sh b/scripts/lint/clang-format.sh new file mode 100755 index 00000000000..041240a6386 --- /dev/null +++ b/scripts/lint/clang-format.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# 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. + +# Formats (or checks) C/C++/Obj-C with the OSS clang-format release, so internal +# and GitHub use identical native formatting. Pass --check to verify without +# writing. Provisions the pinned clang-format from PyPI on first use. + +set -euo pipefail + +CLANG_FORMAT_VERSION="21.1.2" + +CF="clang-format" +if ! "$CF" --version 2>/dev/null | grep -q "$CLANG_FORMAT_VERSION"; then + # PyPI's clang-format wheel bundles the matching LLVM binary (public toolchain). + python3 -m pip install --quiet --user "clang-format==${CLANG_FORMAT_VERSION}" + CF="$(python3 -m site --user-base)/bin/clang-format" +fi + +# Tracked native sources, excluding vendored trees and @generated files +# (generated code is formatted by its generator, not clang-format). +mapfile -t CANDIDATES < <(git ls-files '*.h' '*.cpp' '*.mm' '*.m' | grep -vE 'ReactCommon/yoga/|ReactCommon/jsi/jsi/|/third-party/|/vendor/|/yogajni/|FBXXHashUtils\.h') +FILES=() +for f in "${CANDIDATES[@]}"; do + grep -q '@generated' "$f" 2>/dev/null || FILES+=("$f") +done + +if [ "${1:-}" = "--check" ]; then + "$CF" --dry-run --Werror "${FILES[@]}" +else + "$CF" -i "${FILES[@]}" +fi diff --git a/scripts/lint/ktfmt.sh b/scripts/lint/ktfmt.sh new file mode 100755 index 00000000000..75b6b86040a --- /dev/null +++ b/scripts/lint/ktfmt.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# 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. + +# Formats (or checks) Kotlin with the OSS ktfmt release, so internal and GitHub +# use identical Kotlin formatting. Pass --check to verify without writing. +# Downloads the pinned ktfmt jar on first use (cached under the repo). + +set -euo pipefail + +KTFMT_VERSION="0.64" +CACHE_DIR="${HOME}/.cache/react-native-ktfmt" +JAR="${CACHE_DIR}/ktfmt-${KTFMT_VERSION}-with-dependencies.jar" +URL="https://repo1.maven.org/maven2/com/facebook/ktfmt/${KTFMT_VERSION}/ktfmt-${KTFMT_VERSION}-with-dependencies.jar" + +if [ ! -f "$JAR" ]; then + mkdir -p "$CACHE_DIR" + echo "Downloading ktfmt ${KTFMT_VERSION}..." + curl -fsSL --retry 5 --retry-delay 3 --max-time 600 -o "$JAR" "$URL" +fi + +# ktfmt's default (meta) style matches the repository config: 2-space block +# indent, 4-space continuation, 100 column width. Keep unused imports. +KTFMT_ARGS=(--do-not-remove-unused-imports) +if [ "${1:-}" = "--check" ]; then + KTFMT_ARGS+=(--dry-run --set-exit-if-changed) +fi + +# All tracked Kotlin source except generated / vendored / build outputs. +# `.gradle.kts` build scripts are excluded to match the repository config +# (the ktfmt "scripts" tasks are disabled). +mapfile -t FILES < <(git ls-files '*.kt' | grep -vE '/build/|/hermes-engine/|/internal/featureflags/|systeminfo/ReactNativeVersion\.kt') + +# ktfmt 0.64 requires Java 17+. Prefer JAVA_HOME (GitHub CI's setup-java sets it), +# then fall back to `java` on PATH; error clearly if neither is new enough. +java_major() { + local ver + ver=$("$1" -version 2>&1 | awk -F '"' '/version/ {print $2; exit}') + [ -z "$ver" ] && return 1 + local major=${ver%%.*} + [ "$major" = "1" ] && major=$(printf '%s' "$ver" | awk -F. '{print $2}') + printf '%s' "${major:-0}" +} +JAVA_BIN="" +for cand in "${JAVA_HOME:+$JAVA_HOME/bin/java}" java; do + [ -n "$cand" ] || continue + command -v "$cand" >/dev/null 2>&1 || [ -x "$cand" ] || continue + if [ "$(java_major "$cand" 2>/dev/null || echo 0)" -ge 17 ] 2>/dev/null; then + JAVA_BIN="$cand"; break + fi +done +if [ -z "$JAVA_BIN" ]; then + echo "ktfmt requires Java 17+. Set JAVA_HOME to a JDK 17+ install or put a Java 17+ on PATH." >&2 + exit 1 +fi + +"$JAVA_BIN" -jar "$JAR" "${KTFMT_ARGS[@]}" "${FILES[@]}"