Skip to content

Commit 2de6378

Browse files
authored
feat: support Bedrock API keys (#52)
1 parent ecb9fe2 commit 2de6378

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5322
-6075
lines changed

.github/workflows/release-template.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
name: Release Template
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
reason:
7-
description: 'the reason for triggering this workflow'
8-
required: false
9-
default: 'manually publish the ecr images and templates'
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
108
jobs:
119
release_template:
1210
runs-on: ubuntu-latest

README.md

Lines changed: 152 additions & 157 deletions
Large diffs are not rendered by default.

README_CN.md

Lines changed: 232 additions & 239 deletions
Large diffs are not rendered by default.
-81 KB
Binary file not shown.
-58.9 KB
Binary file not shown.
-180 KB
Binary file not shown.
188 KB
Binary file not shown.

assets/history_settings.avif

9.13 KB
Binary file not shown.

assets/history_settings_zh.avif

5.95 KB
Binary file not shown.

react-native/android/app/build.gradle

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,124 @@ android {
116116
}
117117
}
118118
}
119+
120+
packaging {
121+
resources {
122+
resources.pickFirsts.add('com/facebook/react/modules/network/ProgressiveStringDecoder.class')
123+
}
124+
}
125+
126+
// delete the duplicate class before R8 (only for release builds)
127+
applicationVariants.all { variant ->
128+
// only run during release
129+
if (variant.name.contains('release')) {
130+
def r8Task = tasks.findByName("minify${variant.name.capitalize()}WithR8")
131+
if (r8Task) {
132+
r8Task.doFirst {
133+
// Search and handle all react-android related JAR file
134+
def processedJars = []
135+
136+
// Search Gradle Cached JAR file - support multiple env
137+
def gradleCachePaths = [
138+
file("${System.getProperty('user.home')}/.gradle/caches"),
139+
file("${gradle.gradleUserHomeDir}/caches"),
140+
file("${System.getProperty('GRADLE_USER_HOME', System.getProperty('user.home') + '/.gradle')}/caches")
141+
]
142+
143+
def gradleCache = gradleCachePaths.find { it.exists() }
144+
if (gradleCache) {
145+
println "Using Gradle cache directory: ${gradleCache.absolutePath}"
146+
gradleCache.eachFileRecurse { file ->
147+
if (file.name.contains('react-android') && file.name.endsWith('.jar')) {
148+
def tmpDir = new File("${buildDir}/tmp/modifiedReactAndroid_${file.name}/")
149+
def backupFile = new File("${buildDir}/tmp/backup_${file.name}")
150+
151+
tmpDir.deleteDir()
152+
tmpDir.mkdirs()
153+
backupFile.parentFile.mkdirs()
154+
155+
println "Processing cached react-android JAR: ${file.absolutePath}"
156+
157+
try {
158+
// backup JAR file
159+
copy {
160+
from file
161+
into backupFile.parent
162+
rename { backupFile.name }
163+
}
164+
if (!project.ext.has('backupMap')) {
165+
project.ext.backupMap = [:]
166+
}
167+
project.ext.backupMap[file.absolutePath] = backupFile.absolutePath
168+
println "Backed up ${file.name} to ${backupFile.absolutePath}"
169+
170+
// unzip JAR
171+
copy {
172+
from zipTree(file)
173+
into tmpDir
174+
}
175+
176+
// Delete duplicated class file
177+
def conflictClass = new File("${tmpDir}/com/facebook/react/modules/network/ProgressiveStringDecoder.class")
178+
if (conflictClass.exists()) {
179+
conflictClass.delete()
180+
println "Removed conflicting ProgressiveStringDecoder.class from ${file.name}"
181+
182+
// RePackage JAR
183+
ant.jar(destfile: file) {
184+
fileset(dir: tmpDir)
185+
}
186+
187+
processedJars.add(file.name)
188+
}
189+
} catch (Exception e) {
190+
println "Warning: Could not process ${file.name}: ${e.message}"
191+
}
192+
}
193+
}
194+
} else {
195+
println "No Gradle cache directory found in any of the expected locations"
196+
}
197+
198+
if (processedJars.size() > 0) {
199+
println "Successfully processed ${processedJars.size()} react-android JAR files: ${processedJars}"
200+
} else {
201+
println "No react-android JAR files found to process"
202+
}
203+
}
204+
205+
// revert the changes
206+
r8Task.doLast {
207+
def backupMap = project.ext.has('backupMap') ? project.ext.backupMap : [:]
208+
backupMap.each { originalPath, backupPath ->
209+
try {
210+
def originalFile = new File(originalPath)
211+
def backupFile = new File(backupPath)
212+
213+
if (backupFile.exists()) {
214+
copy {
215+
from backupFile
216+
into originalFile.parent
217+
rename { originalFile.name }
218+
}
219+
backupFile.delete()
220+
println "Restored ${originalFile.name} from backup"
221+
}
222+
} catch (Exception e) {
223+
println "Warning: Could not restore ${originalPath}: ${e.message}"
224+
}
225+
}
226+
227+
if (backupMap.size() > 0) {
228+
println "Successfully restored ${backupMap.size()} JAR files from backup"
229+
if (project.ext.has('backupMap')) {
230+
project.ext.backupMap = [:]
231+
}
232+
}
233+
}
234+
}
235+
}
236+
}
119237
}
120238

121239
dependencies {

0 commit comments

Comments
 (0)