Skip to content

Commit

Permalink
first edition
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonCareter committed Feb 19, 2024
1 parent 70cb42d commit 6c8e6e9
Show file tree
Hide file tree
Showing 69 changed files with 1,048 additions and 2,246 deletions.
113 changes: 34 additions & 79 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,106 +1,61 @@
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
}
ext.safeExtGet = {prop, fallback ->
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
repositories {
google()
gradlePluginPortal()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
}
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

apply plugin: "com.android.library"

apply plugin: 'com.android.library'
if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["FastMlkitTranslateText_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["FastMlkitTranslateText_" + name]).toInteger()
}

def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
return (major == 7 && minor >= 3) || major >= 8
apply plugin: 'com.facebook.react'
}

android {
if (supportsNamespace()) {
namespace "com.fastmlkittranslatetext"
compileSdkVersion safeExtGet('compileSdkVersion', 31)

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 21)
targetSdkVersion safeExtGet('targetSdkVersion', 31)
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
}

compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

}

buildFeatures {
buildConfig true
}

buildTypes {
release {
minifyEnabled false
}
}

lintOptions {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += [
"src/newarch",
// This is needed to build Kotlin project with NewArch enabled
"${project.buildDir}/generated/source/codegen/java"
]
} else {
java.srcDirs += ["src/oldarch"]
}
sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += ['src/newarch']
} else {
java.srcDirs += ['src/oldarch']
}
}
}
}
}

repositories {
mavenCentral()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../node_modules/react-native/android"
}
mavenCentral()
google()
}


dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation 'com.google.mlkit:translate:17.0.2'
implementation 'com.google.mlkit:language-id:17.0.4'
}

if (isNewArchitectureEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifestNew.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.fastmlkittranslatetext">
</manifest>

This file was deleted.

Loading

0 comments on commit 6c8e6e9

Please sign in to comment.