Skip to content

Commit b612007

Browse files
authored
Deprecate old architecture & RN 0.83 upgrade (#32)
* chore: update dependencies to latest versions * feat: pure turbomodule * fix: deprecated code * ci: update ios job to macos 26 runner
1 parent 6bee463 commit b612007

36 files changed

Lines changed: 3479 additions & 4347 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
105105
106106
build-ios:
107-
runs-on: macos-14
107+
runs-on: macos-26
108108
env:
109109
TURBO_CACHE_DIR: .turbo/ios
110110
steps:

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
Since the original [react-native-file-viewer](https://github.com/vinzscam/react-native-file-viewer) is no longer maintained, I decided to fork it and update it to work with the latest React Native versions.
44

5-
This native file viewer for React Native utilizes the QuickLook Framework on iOS and the ACTION_VIEW intent to launch the default app associated with the specified file on Android. It now features TurboModules and Expo support while maintaining backward compatibility with Legacy Native Modules.
5+
This native file viewer for React Native utilizes the QuickLook Framework on iOS and the ACTION_VIEW intent to launch the default app associated with the specified file on Android. It now features TurboModules and Expo support.
6+
7+
## ⚠️ New Architecture Only
8+
9+
**Starting from version 0.7.0, this library supports only the New Architecture.** If you need to support the Old Architecture, please use version 0.6.x or earlier.
610

711
While most of the code remains the same as the original library, I implemented several changes to enhance the overall UI/UX and ensure proper handling of asynchronous logic by using promises instead of EventEmitters where applicable.
812

android/build.gradle

Lines changed: 12 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,38 @@
11
buildscript {
2-
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["FileViewerTurbo_kotlinVersion"]
2+
ext.getExtOrDefault = {name ->
3+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['FileViewerTurbo_' + name]
4+
}
45

56
repositories {
67
google()
78
mavenCentral()
89
}
910

1011
dependencies {
11-
classpath "com.android.tools.build:gradle:7.2.1"
12+
classpath "com.android.tools.build:gradle:8.7.2"
1213
// noinspection DifferentKotlinGradleVersion
13-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
1415
}
1516
}
1617

17-
def reactNativeArchitectures() {
18-
def value = rootProject.getProperties().get("reactNativeArchitectures")
19-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20-
}
21-
22-
def isNewArchitectureEnabled() {
23-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
24-
}
2518

2619
apply plugin: "com.android.library"
2720
apply plugin: "kotlin-android"
2821

29-
if (isNewArchitectureEnabled()) {
30-
apply plugin: "com.facebook.react"
31-
}
32-
33-
def getExtOrDefault(name) {
34-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["FileViewerTurbo_" + name]
35-
}
22+
apply plugin: "com.facebook.react"
3623

3724
def getExtOrIntegerDefault(name) {
3825
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["FileViewerTurbo_" + name]).toInteger()
3926
}
4027

41-
def supportsNamespace() {
42-
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
43-
def major = parsed[0].toInteger()
44-
def minor = parsed[1].toInteger()
45-
46-
// Namespace support was added in 7.3.0
47-
return (major == 7 && minor >= 3) || major >= 8
48-
}
49-
5028
android {
51-
if (supportsNamespace()) {
52-
namespace "com.fileviewerturbo"
53-
54-
sourceSets {
55-
main {
56-
manifest.srcFile "src/main/AndroidManifestNew.xml"
57-
}
58-
}
59-
}
29+
namespace "com.fileviewerturbo"
6030

6131
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
6232

6333
defaultConfig {
6434
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
6535
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
66-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
67-
}
68-
69-
sourceSets {
70-
main {
71-
if (isNewArchitectureEnabled()) {
72-
java.srcDirs += ['src/newarch']
73-
} else {
74-
java.srcDirs += ['src/oldarch']
75-
}
76-
}
7736
}
7837

7938
buildFeatures {
@@ -97,12 +56,10 @@ android {
9756

9857
sourceSets {
9958
main {
100-
if (isNewArchitectureEnabled()) {
101-
java.srcDirs += [
102-
"generated/java",
103-
"generated/jni"
104-
]
105-
}
59+
java.srcDirs += [
60+
"generated/java",
61+
"generated/jni"
62+
]
10663
}
10764
}
10865
}
@@ -115,17 +72,6 @@ repositories {
11572
def kotlin_version = getExtOrDefault("kotlinVersion")
11673

11774
dependencies {
118-
// For < 0.71, this will be from the local maven repo
119-
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
120-
//noinspection GradleDynamicVersion
121-
implementation "com.facebook.react:react-native:+"
75+
implementation "com.facebook.react:react-android"
12276
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
12377
}
124-
125-
if (isNewArchitectureEnabled()) {
126-
react {
127-
jsRootDir = file("../src/")
128-
libraryName = "FileViewerTurbo"
129-
codegenJavaPackageName = "com.fileviewerturbo"
130-
}
131-
}

android/gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FileViewerTurbo_kotlinVersion=1.7.0
2-
FileViewerTurbo_minSdkVersion=21
3-
FileViewerTurbo_targetSdkVersion=31
4-
FileViewerTurbo_compileSdkVersion=31
5-
FileViewerTurbo_ndkversion=21.4.7075529
1+
FileViewerTurbo_kotlinVersion=2.0.21
2+
FileViewerTurbo_minSdkVersion=24
3+
FileViewerTurbo_targetSdkVersion=34
4+
FileViewerTurbo_compileSdkVersion=35
5+
FileViewerTurbo_ndkversion=27.1.12297006
-42.4 KB
Binary file not shown.

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)