Skip to content

Commit 22f4c82

Browse files
authored
Merge pull request #127 from callstack/refactor/android-kotlin
refactor: module android impl from Java to Kotlin
2 parents fd0c87b + 401a056 commit 22f4c82

File tree

15 files changed

+679
-720
lines changed

15 files changed

+679
-720
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
- name: Lint files
4343
run: yarn lint
4444

45+
- name: Lint Android files
46+
run: yarn lint:android
47+
4548
- name: Types check
4649
run: yarn ts
4750

android/build.gradle

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
buildscript {
22
repositories {
3-
google()
43
mavenCentral()
4+
google()
55
}
66

7+
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNImageEditor_kotlinVersion']
8+
def spotless_version = project.properties['RNImageEditor_spotlessVersion']
9+
710
dependencies {
811
classpath "com.android.tools.build:gradle:7.2.1"
12+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13+
classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotless_version"
914
}
1015
}
1116

1217
def isNewArchitectureEnabled() {
1318
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
1419
}
1520

21+
if (project == rootProject) {
22+
apply from: 'spotless.gradle'
23+
}
24+
1625
apply plugin: "com.android.library"
26+
apply plugin: "kotlin-android"
1727

1828
if (isNewArchitectureEnabled()) {
1929
apply plugin: "com.facebook.react"
@@ -70,6 +80,9 @@ android {
7080
sourceCompatibility JavaVersion.VERSION_1_8
7181
targetCompatibility JavaVersion.VERSION_1_8
7282
}
83+
packagingOptions {
84+
resources.excludes += "DebugProbesKt.bin"
85+
}
7386

7487
sourceSets {
7588
main {
@@ -87,9 +100,14 @@ repositories {
87100
google()
88101
}
89102

103+
def kotlinx_coroutines_version = getExtOrDefault('kotlinxCoroutinesVersion')
104+
def androidx_exifinterface_version = getExtOrDefault('androidxExifinterfaceVersion')
105+
90106
dependencies {
91107
// For < 0.71, this will be from the local maven repo
92108
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
93109
//noinspection GradleDynamicVersion
94110
implementation "com.facebook.react:react-native:+"
111+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinx_coroutines_version"
112+
implementation "androidx.exifinterface:exifinterface:$androidx_exifinterface_version"
95113
}

android/gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
RNImageEditor_compileSdkVersion=34
22
RNImageEditor_targetSdkVersion=34
33
RNImageEditor_minSdkVersion=21
4+
RNImageEditor_kotlinxCoroutinesVersion=1.7.3
5+
RNImageEditor_androidxExifinterfaceVersion=1.3.6
6+
RNImageEditor_kotlinVersion=1.7.22
7+
RNImageEditor_spotlessVersion=6.22.0

android/gradlew

100644100755
File mode changed.

android/gradlew.bat

100644100755
Lines changed: 84 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/spotless.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// formatter & linter configuration for kotlin
2+
apply plugin: 'com.diffplug.spotless'
3+
4+
spotless {
5+
java {
6+
target 'src/*/java/**/*.java'
7+
googleJavaFormat()
8+
}
9+
kotlin {
10+
target 'src/**/*.kt'
11+
ktfmt('0.46').kotlinlangStyle()
12+
trimTrailingWhitespace()
13+
indentWithSpaces()
14+
endWithNewline()
15+
}
16+
}

0 commit comments

Comments
 (0)