Skip to content

Commit 7dce8e2

Browse files
committed
feat!: sdk 52 support
1 parent 30b22ab commit 7dce8e2

21 files changed

+6727
-8251
lines changed

.changeset/brave-bananas-peel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"expo-speech-recognition": major
3+
---
4+
5+
Support for SDK 52.

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ function App() {
168168
{!recognizing ? (
169169
<Button title="Start" onPress={handleStart} />
170170
) : (
171-
<Button title="Stop" onPress={ExpoSpeechRecognitionModule.stop} />
171+
<Button
172+
title="Stop"
173+
onPress={() => ExpoSpeechRecognitionModule.stop()}
174+
/>
172175
)}
173176

174177
<ScrollView>

example/App.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ export default function App() {
208208
<BigButton
209209
title="Stop"
210210
disabled={status !== "recognizing"}
211-
onPress={ExpoSpeechRecognitionModule.stop}
211+
onPress={() => ExpoSpeechRecognitionModule.stop()}
212212
/>
213213
<BigButton
214214
title="Abort"
215215
disabled={status !== "recognizing"}
216-
onPress={ExpoSpeechRecognitionModule.abort}
216+
onPress={() => ExpoSpeechRecognitionModule.abort()}
217217
/>
218218
</View>
219219
)}

example/android/app/build.gradle

+13-38
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@ apply plugin: "com.facebook.react"
44

55
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
66

7-
static def versionToNumber(major, minor, patch) {
8-
return patch * 100 + minor * 10000 + major * 1000000
9-
}
10-
11-
def getRNVersion() {
12-
def version = providers.exec {
13-
workingDir(projectDir)
14-
commandLine("node", "-e", "console.log(require('react-native/package.json').version);")
15-
}.standardOutput.asText.get().trim()
16-
17-
def coreVersion = version.split("-")[0]
18-
def (major, minor, patch) = coreVersion.tokenize('.').collect { it.toInteger() }
19-
20-
return versionToNumber(
21-
major,
22-
minor,
23-
patch
24-
)
25-
}
26-
def rnVersion = getRNVersion()
27-
287
/**
298
* This is the configuration block to customize your React Native Android app.
309
* By default you don't need to apply any configuration, just uncomment the lines you need.
@@ -41,12 +20,12 @@ react {
4120
bundleCommand = "export:embed"
4221

4322
/* Folders */
44-
// The root of your project, i.e. where "package.json" lives. Default is '..'
45-
// root = file("../")
46-
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
47-
// reactNativeDir = file("../node_modules/react-native")
48-
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
49-
// codegenDir = file("../node_modules/@react-native/codegen")
23+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
24+
// root = file("../../")
25+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
26+
// reactNativeDir = file("../../node_modules/react-native")
27+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
28+
// codegenDir = file("../../node_modules/@react-native/codegen")
5029

5130
/* Variants */
5231
// The list of variants to that are debuggable. For those we're going to
@@ -79,10 +58,8 @@ react {
7958
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
8059
// hermesFlags = ["-O", "-output-source-map"]
8160

82-
if (rnVersion >= versionToNumber(0, 75, 0)) {
83-
/* Autolinking */
84-
autolinkLibrariesWithApp()
85-
}
61+
/* Autolinking */
62+
autolinkLibrariesWithApp()
8663
}
8764

8865
/**
@@ -109,9 +86,9 @@ android {
10986
buildToolsVersion rootProject.ext.buildToolsVersion
11087
compileSdk rootProject.ext.compileSdkVersion
11188

112-
namespace 'expo.modules.speechrecognition.example'
89+
namespace 'expo.modules.settingstwo.example'
11390
defaultConfig {
114-
applicationId 'expo.modules.speechrecognition.example'
91+
applicationId 'expo.modules.settingstwo.example'
11592
minSdkVersion rootProject.ext.minSdkVersion
11693
targetSdkVersion rootProject.ext.targetSdkVersion
11794
versionCode 1
@@ -144,6 +121,9 @@ android {
144121
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
145122
}
146123
}
124+
androidResources {
125+
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
126+
}
147127
}
148128

149129
// Apply static values from `gradle.properties` to the `android.packagingOptions`
@@ -194,8 +174,3 @@ dependencies {
194174
implementation jscFlavor
195175
}
196176
}
197-
198-
if (rnVersion < versionToNumber(0, 75, 0)) {
199-
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
200-
applyNativeModulesAppBuildGradle(project)
201-
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
22
<uses-permission android:name="android.permission.INTERNET"/>
3-
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
43
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
5-
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
64
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
75
<uses-permission android:name="android.permission.VIBRATE"/>
86
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
@@ -13,19 +11,7 @@
1311
<data android:scheme="https"/>
1412
</intent>
1513
</queries>
16-
<queries>
17-
<package android:name="com.google.android.googlequicksearchbox"/>
18-
<intent>
19-
<action android:name="android.speech.RecognitionService"/>
20-
</intent>
21-
</queries>
22-
<queries>
23-
<package android:name="com.google.android.tts"/>
24-
<intent>
25-
<action android:name="android.speech.RecognitionService"/>
26-
</intent>
27-
</queries>
28-
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
14+
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true">
2915
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
3016
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
3117
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
@@ -41,6 +27,5 @@
4127
<data android:scheme="expo.modules.speechrecognition.example"/>
4228
</intent-filter>
4329
</activity>
44-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
4530
</application>
4631
</manifest>

example/android/app/src/main/java/expo/modules/speechrecognition/example/MainApplication.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.facebook.react.ReactPackage
1010
import com.facebook.react.ReactHost
1111
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
1212
import com.facebook.react.defaults.DefaultReactNativeHost
13+
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1314
import com.facebook.soloader.SoLoader
1415

1516
import expo.modules.ApplicationLifecycleDispatcher
@@ -21,9 +22,10 @@ class MainApplication : Application(), ReactApplication {
2122
this,
2223
object : DefaultReactNativeHost(this) {
2324
override fun getPackages(): List<ReactPackage> {
25+
val packages = PackageList(this).packages
2426
// Packages that cannot be autolinked yet can be added manually here, for example:
2527
// packages.add(new MyReactNativePackage());
26-
return PackageList(this).packages
28+
return packages
2729
}
2830

2931
override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
@@ -40,7 +42,7 @@ class MainApplication : Application(), ReactApplication {
4042

4143
override fun onCreate() {
4244
super.onCreate()
43-
SoLoader.init(this, false)
45+
SoLoader.init(this, OpenSourceMergedSoMapping)
4446
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
4547
// If you opted-in for the New Architecture, we load the native entry point for this app.
4648
load()

example/android/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
6-
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
7-
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
5+
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '35.0.0'
6+
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
7+
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
88
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
9-
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.23'
9+
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.24'
1010

1111
ndkVersion = "26.1.10909125"
1212
}

example/android/gradle.properties

-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
2222
# https://developer.android.com/topic/libraries/support-library/androidx-rn
2323
android.useAndroidX=true
2424

25-
# Automatically convert third-party libraries to use AndroidX
26-
android.enableJetifier=true
27-
2825
# Enable AAPT2 PNG crunching
2926
android.enablePngCrunchInReleaseBuilds=true
3027

@@ -57,5 +54,3 @@ EX_DEV_CLIENT_NETWORK_INSPECTOR=true
5754

5855
# Use legacy packaging to compress native libraries in the resulting APK.
5956
expo.useLegacyPackaging=false
60-
61-
android.extraMavenRepos=[]

example/android/gradlew

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
8891

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

example/android/gradlew.bat

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

example/android/react-settings-plugin/build.gradle.kts

-19
This file was deleted.

example/android/react-settings-plugin/src/main/kotlin/expo/plugins/ReactSettingsPlugin.kt

-10
This file was deleted.

example/android/settings.gradle

+17-45
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,27 @@
11
pluginManagement {
2-
def version = providers.exec {
3-
commandLine("node", "-e", "console.log(require('react-native/package.json').version);")
4-
}.standardOutput.asText.get().trim()
5-
def (_, reactNativeMinor, reactNativePatch) = version.split("-")[0].tokenize('.').collect { it.toInteger() }
6-
7-
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
8-
if(reactNativeMinor == 74 && reactNativePatch <= 3){
9-
includeBuild("react-settings-plugin")
10-
}
2+
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
113
}
12-
134
plugins { id("com.facebook.react.settings") }
145

15-
def getRNMinorVersion() {
16-
def version = providers.exec {
17-
commandLine("node", "-e", "console.log(require('react-native/package.json').version);")
18-
}.standardOutput.asText.get().trim()
19-
20-
def coreVersion = version.split("-")[0]
21-
def (major, minor, patch) = coreVersion.tokenize('.').collect { it.toInteger() }
22-
23-
return minor
24-
}
25-
26-
if (getRNMinorVersion() >= 75) {
27-
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
28-
if (System.getenv('EXPO_UNSTABLE_CORE_AUTOLINKING') == '1') {
29-
println('\u001B[32mUsing expo-modules-autolinking as core autolinking source\u001B[0m')
30-
def command = [
31-
'node',
32-
'--no-warnings',
33-
'--eval',
34-
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
35-
'react-native-config',
36-
'--json',
37-
'--platform',
38-
'android'
39-
].toList()
40-
ex.autolinkLibrariesFromCommand(command)
41-
} else {
42-
ex.autolinkLibrariesFromCommand()
43-
}
6+
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
7+
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
8+
ex.autolinkLibrariesFromCommand()
9+
} else {
10+
def command = [
11+
'node',
12+
'--no-warnings',
13+
'--eval',
14+
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
15+
'react-native-config',
16+
'--json',
17+
'--platform',
18+
'android'
19+
].toList()
20+
ex.autolinkLibrariesFromCommand(command)
4421
}
4522
}
4623

47-
rootProject.name = 'expo-speech-recognition-example'
24+
rootProject.name = 'expo-settings-two-example'
4825

4926
dependencyResolutionManagement {
5027
versionCatalogs {
@@ -57,10 +34,5 @@ dependencyResolutionManagement {
5734
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
5835
useExpoModules()
5936

60-
if (getRNMinorVersion() < 75) {
61-
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
62-
applyNativeModulesSettingsGradle(settings)
63-
}
64-
6537
include ':app'
6638
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile())

0 commit comments

Comments
 (0)