react-native-legal 1.6.5 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/Package.swift +56 -0
  2. package/android/build.gradle +44 -30
  3. package/android/src/main/java/com/reactnativelegal/ReactNativeLegalActivity.kt +73 -76
  4. package/android/src/main/java/com/reactnativelegal/ReactNativeLegalModuleImpl.kt +24 -6
  5. package/android/src/main/res/layout/activity_licenses.xml +4 -26
  6. package/android/src/main/res/values/styles.xml +1 -3
  7. package/bare-plugin/build/android/addListActivity.js +2 -2
  8. package/bare-plugin/build/android/addResourceKeepFile.d.ts +4 -0
  9. package/bare-plugin/build/android/addResourceKeepFile.js +10 -0
  10. package/bare-plugin/build/android/androidCommand.js +2 -0
  11. package/bare-plugin/build/android/applyAndConfigureAboutLibrariesPlugin.js +5 -5
  12. package/bare-plugin/build/android/declareAboutLibrariesPlugin.js +5 -5
  13. package/bare-plugin/src/android/addListActivity.ts +1 -1
  14. package/bare-plugin/src/android/addResourceKeepFile.ts +8 -0
  15. package/bare-plugin/src/android/androidCommand.ts +2 -0
  16. package/bare-plugin/src/android/applyAndConfigureAboutLibrariesPlugin.ts +2 -2
  17. package/bare-plugin/src/android/declareAboutLibrariesPlugin.ts +2 -2
  18. package/bare-plugin/tsconfig.json +4 -3
  19. package/ios/ReactNativeLegalDetailViewController.swift +2 -0
  20. package/ios/ReactNativeLegalModule.mm +12 -1
  21. package/ios/ReactNativeLegalModuleImpl.swift +5 -2
  22. package/ios/ReactNativeLegalTableViewController.swift +2 -0
  23. package/package.json +4 -1
  24. package/plugin/build/android/addResourceKeepFile.d.ts +5 -0
  25. package/plugin/build/android/addResourceKeepFile.js +17 -0
  26. package/plugin/build/android/withAndroidLegal.js +2 -0
  27. package/plugin/src/android/addResourceKeepFile.ts +17 -0
  28. package/plugin/src/android/withAndroidLegal.ts +2 -0
  29. package/plugin-utils/build/android.d.ts +4 -0
  30. package/plugin-utils/build/android.js +82 -23
  31. package/plugin-utils/build/ios.js +13 -3
  32. package/plugin-utils/src/android.ts +99 -27
  33. package/plugin-utils/src/ios.ts +19 -3
  34. package/plugin-utils/tsconfig.json +5 -4
  35. package/swift-tools/Package.resolved +96 -0
  36. package/swift-tools/Package.swift +15 -0
  37. package/android/src/main/res/values/colors.xml +0 -3
  38. package/android/src/main/res/values-night/colors.xml +0 -3
package/Package.swift ADDED
@@ -0,0 +1,56 @@
1
+ // swift-tools-version: 6.0
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "ReactNativeLegal",
6
+ platforms: [.iOS(.v15), .tvOS(.v15)],
7
+ products: [
8
+ .library(name: "ReactNativeLegal", targets: ["ReactNativeLegalObjC"]),
9
+ ],
10
+ dependencies: [
11
+ .package(name: "ReactNative", path: "../../../../xcframeworks"),
12
+ .package(name: "React-GeneratedCode", path: "../../../ios"),
13
+ ],
14
+ targets: [
15
+ .target(
16
+ name: "ReactNativeLegalSwift",
17
+ path: ".",
18
+ sources: [
19
+ "ios/ReactNativeLegalDetailViewController.swift",
20
+ "ios/ReactNativeLegalLicenseMetadata.swift",
21
+ "ios/ReactNativeLegalModuleImpl.swift",
22
+ "ios/ReactNativeLegalTableViewController.swift",
23
+ ],
24
+ publicHeadersPath: "ios",
25
+ cSettings: [.headerSearchPath("ios")],
26
+ cxxSettings: [.headerSearchPath("ios"), .define("DEBUG", .when(configuration: .debug)), .define("NDEBUG", .when(configuration: .release))],
27
+ linkerSettings: [.linkedFramework("UIKit"), .linkedFramework("Foundation"), .linkedFramework("CoreGraphics")]
28
+ ),
29
+ .target(
30
+ name: "ReactNativeLegalObjC",
31
+ dependencies: [
32
+ "ReactNativeLegalSwift",
33
+ .product(name: "ReactHeaders", package: "ReactNative"),
34
+ .product(name: "ReactNativeHeaders", package: "ReactNative"),
35
+ .product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
36
+ .product(name: "ReactAppHeaders", package: "React-GeneratedCode"),
37
+ ],
38
+ path: ".",
39
+ sources: [
40
+ "ios/ReactNativeLegalModule.h",
41
+ "ios/ReactNativeLegalModule.mm",
42
+ ],
43
+ publicHeadersPath: "ios",
44
+ cSettings: [.headerSearchPath("ios"), .define("REACT_NATIVE_LEGAL_USING_SPM")],
45
+ cxxSettings: [
46
+ .headerSearchPath("ios"),
47
+ .define("REACT_NATIVE_LEGAL_USING_SPM"),
48
+ .define("DEBUG", .when(configuration: .debug)),
49
+ .define("NDEBUG", .when(configuration: .release)),
50
+ .unsafeFlags(["-fmodules", "-fcxx-modules"])
51
+ ],
52
+ linkerSettings: [.linkedFramework("UIKit"), .linkedFramework("Foundation"), .linkedFramework("CoreGraphics")]
53
+ )
54
+ ],
55
+ cxxLanguageStandard: .cxx20
56
+ )
@@ -1,53 +1,62 @@
1
1
  buildscript {
2
- ext.safeExtGet = {prop, fallback ->
3
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
4
- }
5
-
6
- def kotlin_version = safeExtGet('kotlinVersion', '1.7.22')
2
+ def agp_version = rootProject.ext.has('androidGradlePluginVersion') ? rootProject.ext.get('androidGradlePluginVersion') : project.properties['ReactNativeLegal_androidGradlePluginVersion']
3
+ def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['ReactNativeLegal_kotlinVersion']
7
4
 
8
5
  repositories {
9
6
  google()
10
7
  gradlePluginPortal()
11
8
  }
12
9
  dependencies {
13
- classpath("com.android.tools.build:gradle:7.2.1")
14
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
15
- classpath("com.diffplug.spotless:com.diffplug.spotless.gradle.plugin:7.0.2")
10
+ classpath("com.android.tools.build:gradle:$agp_version")
11
+ classpath("org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:$kotlin_version")
12
+ classpath("com.diffplug.spotless:com.diffplug.spotless.gradle.plugin:8.10.2")
16
13
  }
17
14
  }
18
15
 
19
- def isNewArchitectureEnabled() {
20
- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
21
- }
22
-
23
16
  if (project == rootProject) {
24
17
  apply from: 'spotless.gradle'
25
18
  }
26
19
 
27
20
  apply plugin: 'com.android.library'
28
- apply plugin: 'kotlin-android'
29
- if (isNewArchitectureEnabled()) {
21
+ // AGP 9 ships built-in Kotlin support and registers the `kotlin` extension
22
+ // itself. Applying the Kotlin plugin on top of it fails configuration with
23
+ // "Cannot add extension with name 'kotlin'". Only apply it when nothing has
24
+ // registered that extension yet.
25
+ if (project.extensions.findByName('kotlin') == null) {
26
+ apply plugin: 'kotlin-android'
27
+ }
28
+
29
+ if (project != rootProject) {
30
30
  apply plugin: "com.facebook.react"
31
31
  }
32
32
 
33
+ apply plugin: "org.jetbrains.kotlin.plugin.compose"
34
+
35
+ def getOrExtDefault(name) {
36
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeLegal_' + name]
37
+ }
38
+
39
+ def getOrExtIntegerDefault(name) {
40
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeLegal_' + name]).toInteger()
41
+ }
42
+
33
43
  android {
34
- compileSdkVersion safeExtGet('compileSdkVersion', 33)
44
+ compileSdkVersion getOrExtIntegerDefault('compileSdkVersion')
35
45
 
36
46
  namespace "com.reactnativelegal"
37
47
 
38
48
  defaultConfig {
39
- minSdkVersion safeExtGet('minSdkVersion', 21)
40
- targetSdkVersion safeExtGet('targetSdkVersion', 33)
41
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
49
+ minSdkVersion getOrExtIntegerDefault('minSdkVersion')
50
+ targetSdkVersion getOrExtIntegerDefault('targetSdkVersion')
51
+ }
52
+
53
+ buildFeatures {
54
+ compose true
42
55
  }
43
56
 
44
57
  sourceSets {
45
58
  main {
46
- if (isNewArchitectureEnabled()) {
47
- java.srcDirs += ['src/newarch/java', "${project.buildDir}/generated/source/codegen/java"]
48
- } else {
49
- java.srcDirs += ['src/oldarch/java']
50
- }
59
+ java.srcDirs += ['src/newarch/java', "${project.buildDir}/generated/source/codegen/java"]
51
60
  }
52
61
  }
53
62
  }
@@ -63,12 +72,17 @@ repositories {
63
72
  dependencies {
64
73
  implementation "com.facebook.react:react-android" // Set by the React Native Gradle Plugin
65
74
 
66
- def aboutLibrariesPluginVersion = "10.8.3"
67
- implementation("com.mikepenz:aboutlibraries-core-android:$aboutLibrariesPluginVersion")
68
- implementation("com.mikepenz:aboutlibraries:$aboutLibrariesPluginVersion") {
69
- exclude group: 'com.mikepenz', module: 'aboutlibraries-core'
70
- }
75
+ def aboutLibrariesVersion = getOrExtDefault('aboutLibrariesVersion')
76
+ implementation("com.mikepenz:aboutlibraries-core:$aboutLibrariesVersion")
77
+ implementation("com.mikepenz:aboutlibraries-compose-m3:$aboutLibrariesVersion")
71
78
 
72
- def constraintLayoutVersion = "2.1.4"
73
- implementation("androidx.constraintlayout:constraintlayout:$constraintLayoutVersion")
79
+ def composeBomVersion = getOrExtDefault('composeBomVersion')
80
+ Dependency composeBom = platform("androidx.compose:compose-bom:$composeBomVersion")
81
+ implementation composeBom
82
+ implementation("androidx.compose.foundation:foundation")
83
+ implementation("androidx.compose.material:material")
84
+ implementation("androidx.compose.material:material-icons-core")
85
+ implementation("androidx.compose.material3:material3")
86
+ implementation("androidx.compose.runtime:runtime")
87
+ implementation("androidx.compose.ui:ui")
74
88
  }
@@ -5,25 +5,39 @@ import android.content.res.Configuration
5
5
  import android.graphics.Color
6
6
  import android.os.Build
7
7
  import android.os.Bundle
8
- import android.view.MenuItem
9
- import android.view.View
10
8
  import android.view.WindowManager
11
9
  import androidx.appcompat.app.AppCompatActivity
12
- import androidx.appcompat.widget.Toolbar
10
+ import androidx.compose.foundation.isSystemInDarkTheme
11
+ import androidx.compose.foundation.layout.Arrangement
12
+ import androidx.compose.foundation.layout.Column
13
+ import androidx.compose.foundation.layout.fillMaxSize
14
+ import androidx.compose.foundation.layout.padding
15
+ import androidx.compose.material.icons.Icons
16
+ import androidx.compose.material.icons.automirrored.filled.ArrowBack
17
+ import androidx.compose.material3.CenterAlignedTopAppBar
18
+ import androidx.compose.material3.ExperimentalMaterial3Api
19
+ import androidx.compose.material3.Icon
20
+ import androidx.compose.material3.IconButton
21
+ import androidx.compose.material3.MaterialTheme
22
+ import androidx.compose.material3.Scaffold
23
+ import androidx.compose.material3.Text
24
+ import androidx.compose.material3.TopAppBarDefaults
25
+ import androidx.compose.material3.darkColorScheme
26
+ import androidx.compose.material3.lightColorScheme
27
+ import androidx.compose.material3.rememberTopAppBarState
28
+ import androidx.compose.runtime.getValue
29
+ import androidx.compose.ui.Alignment
30
+ import androidx.compose.ui.Modifier
31
+ import androidx.compose.ui.input.nestedscroll.nestedScroll
32
+ import androidx.compose.ui.platform.ComposeView
33
+ import androidx.compose.ui.text.style.TextOverflow
13
34
  import androidx.core.view.WindowCompat
14
- import androidx.core.view.WindowInsetsCompat
15
35
  import androidx.core.view.WindowInsetsControllerCompat
16
- import androidx.core.view.updatePadding
17
- import com.mikepenz.aboutlibraries.LibsBuilder.Companion.BUNDLE_TITLE
18
- import com.mikepenz.aboutlibraries.ui.LibsSupportFragment
36
+ import com.mikepenz.aboutlibraries.ui.compose.android.produceLibraries
37
+ import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer
19
38
 
20
- /**
21
- * Based on AboutLibraries LibsActivity, but simplified (no search filter), with improved back
22
- * handling and hidden Toolbar/ActionBar for TV devices
23
- */
39
+ @OptIn(ExperimentalMaterial3Api::class)
24
40
  class ReactNativeLegalActivity : AppCompatActivity() {
25
- private lateinit var fragment: LibsSupportFragment
26
-
27
41
  override fun onCreate(savedInstanceState: Bundle?) {
28
42
  setTheme(R.style.ReactNativeLegalTheme)
29
43
  super.onCreate(savedInstanceState)
@@ -32,75 +46,58 @@ class ReactNativeLegalActivity : AppCompatActivity() {
32
46
  setupEdgeToEdge()
33
47
 
34
48
  val bundle = intent.extras
35
- fragment = LibsSupportFragment().apply { arguments = bundle }
49
+ val id = bundle?.getInt("id") ?: -1
50
+ val title = bundle?.getString("title", "") ?: ""
51
+ val composeView = findViewById<ComposeView>(R.id.compose_view)
36
52
 
37
53
  // https://developer.android.com/training/tv/start/hardware.html#runtime-check
38
54
  val isTVDevice = packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
39
55
 
40
- if (isTVDevice) {
41
- hideToolbar()
42
- } else {
43
- setupToolbar(bundle)
44
- }
45
-
46
- supportFragmentManager
47
- .beginTransaction()
48
- .replace(R.id.fragment_container, fragment)
49
- .commit()
50
- }
51
-
52
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
53
- if (item.itemId == android.R.id.home) {
54
- onBackPressedDispatcher.onBackPressed()
55
- return true
56
- }
57
- return super.onOptionsItemSelected(item)
58
- }
59
-
60
- private fun hideToolbar() {
61
- val toolbar = findViewById<Toolbar>(R.id.toolbar)
62
- toolbar.visibility = View.GONE
63
- supportActionBar?.hide()
64
- }
65
-
66
- private fun setupToolbar(bundle: Bundle?) {
67
- val title = bundle?.getString(BUNDLE_TITLE, "") ?: ""
68
-
69
- val toolbar = findViewById<Toolbar>(R.id.toolbar)
70
- setSupportActionBar(toolbar)
71
-
72
- supportActionBar?.let {
73
- it.setDisplayHomeAsUpEnabled(true)
74
- it.setDisplayShowTitleEnabled(title.isNotEmpty())
75
- it.title = title
76
- }
77
-
78
- toolbar.setOnApplyWindowInsetsListener { v, insets ->
79
- val systemInsets =
80
- WindowInsetsCompat.toWindowInsetsCompat(insets)
81
- .getInsets(WindowInsetsCompat.Type.systemBars())
82
- v.updatePadding(
83
- left = systemInsets.left,
84
- top = systemInsets.top,
85
- right = systemInsets.right,
86
- )
87
-
88
- insets
89
- }
90
-
91
- if (toolbar.isAttachedToWindow) {
92
- toolbar.requestApplyInsets()
93
- } else {
94
- toolbar.addOnAttachStateChangeListener(
95
- object : View.OnAttachStateChangeListener {
96
- override fun onViewAttachedToWindow(v: View) {
97
- v.removeOnAttachStateChangeListener(this)
98
- v.requestApplyInsets()
56
+ composeView.setContent {
57
+ val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
58
+
59
+ MaterialTheme(
60
+ colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
61
+ ) {
62
+ Scaffold(
63
+ modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
64
+ topBar = {
65
+ if (!isTVDevice) {
66
+ CenterAlignedTopAppBar(
67
+ title = {
68
+ Text(title, maxLines = 1, overflow = TextOverflow.Ellipsis)
69
+ },
70
+ navigationIcon = {
71
+ IconButton(
72
+ onClick = { onBackPressedDispatcher.onBackPressed() }
73
+ ) {
74
+ Icon(
75
+ imageVector = Icons.AutoMirrored.Filled.ArrowBack,
76
+ contentDescription = "Go back",
77
+ )
78
+ }
79
+ },
80
+ )
81
+ }
82
+ },
83
+ ) { innerPadding ->
84
+ if (id == -1) {
85
+ Column(
86
+ modifier = Modifier.fillMaxSize().padding(innerPadding),
87
+ horizontalAlignment = Alignment.CenterHorizontally,
88
+ verticalArrangement = Arrangement.Center,
89
+ ) {
90
+ Text("Incorrect resource identifier provided")
91
+ }
92
+ } else {
93
+ val libraries by produceLibraries(id)
94
+ LibrariesContainer(
95
+ libraries = libraries,
96
+ modifier = Modifier.fillMaxSize().padding(innerPadding),
97
+ )
99
98
  }
100
-
101
- override fun onViewDetachedFromWindow(v: View) = Unit
102
99
  }
103
- )
100
+ }
104
101
  }
105
102
  }
106
103
 
@@ -1,5 +1,6 @@
1
1
  package com.reactnativelegal
2
2
 
3
+ import android.content.Context
3
4
  import android.content.Intent
4
5
  import android.os.Bundle
5
6
  import androidx.core.os.bundleOf
@@ -7,20 +8,20 @@ import com.facebook.react.bridge.Arguments
7
8
  import com.facebook.react.bridge.ReactApplicationContext
8
9
  import com.facebook.react.bridge.WritableMap
9
10
  import com.mikepenz.aboutlibraries.Libs
10
- import com.mikepenz.aboutlibraries.LibsBuilder
11
- import com.mikepenz.aboutlibraries.util.withContext
12
11
 
13
12
  object ReactNativeLegalModuleImpl {
14
13
  const val NAME = "ReactNativeLegalModule"
15
14
 
16
15
  private var cachedData: List<Bundle>? = null
16
+ private var cachedId: Int = -1
17
17
 
18
18
  fun launchLicenseListScreen(reactContext: ReactApplicationContext, licenseHeaderText: String) {
19
19
  val context = reactContext.currentActivity ?: return
20
+ val id = getOrInitLibrariesResourceIdentifier(context)
20
21
  val intent =
21
22
  Intent(context, ReactNativeLegalActivity::class.java).apply {
22
- this.putExtra("data", LibsBuilder())
23
- this.putExtra(LibsBuilder.BUNDLE_TITLE, licenseHeaderText)
23
+ this.putExtra("id", id)
24
+ this.putExtra("title", licenseHeaderText)
24
25
  }
25
26
 
26
27
  context.startActivity(intent)
@@ -31,14 +32,31 @@ object ReactNativeLegalModuleImpl {
31
32
  cachedData = retrieveLibrariesArray(reactContext)
32
33
  }
33
34
 
34
- val libraries = cachedData ?: emptyList<Bundle>()
35
+ val libraries = cachedData ?: emptyList()
35
36
  return Arguments.createMap().apply { putArray("data", Arguments.fromList(libraries)) }
36
37
  }
37
38
 
39
+ private fun getOrInitLibrariesResourceIdentifier(context: Context): Int {
40
+ if (cachedId == -1) {
41
+ cachedId =
42
+ context.resources.getIdentifier(
43
+ "aboutlibraries",
44
+ "raw",
45
+ context.packageName,
46
+ )
47
+ }
48
+ return cachedId
49
+ }
50
+
38
51
  private fun retrieveLibrariesArray(reactContext: ReactApplicationContext): List<Bundle>? {
39
52
  val context = reactContext.currentActivity ?: return null
40
53
 
41
- val libraries = Libs.Builder().withContext(context).build().libraries
54
+ val jsonString =
55
+ context.resources
56
+ .openRawResource(getOrInitLibrariesResourceIdentifier(context))
57
+ .bufferedReader()
58
+ .use { it.readText() }
59
+ val libraries = Libs.Builder().withJson(jsonString).build().libraries
42
60
 
43
61
  return libraries.map { library ->
44
62
  bundleOf(
@@ -1,28 +1,6 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
- xmlns:app="http://schemas.android.com/apk/res-auto"
2
+ <androidx.compose.ui.platform.ComposeView
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ android:id="@+id/compose_view"
4
5
  android:layout_width="match_parent"
5
- android:layout_height="match_parent">
6
-
7
- <androidx.appcompat.widget.Toolbar
8
- android:id="@+id/toolbar"
9
- style="?toolbarStyle"
10
- android:layout_width="0dp"
11
- android:layout_height="wrap_content"
12
- app:contentInsetStart="0dp"
13
- app:contentInsetStartWithNavigation="0dp"
14
- app:elevation="4dp"
15
- app:layout_constraintEnd_toEndOf="parent"
16
- app:layout_constraintStart_toStartOf="parent"
17
- app:layout_constraintTop_toTopOf="parent" />
18
-
19
- <androidx.fragment.app.FragmentContainerView
20
- android:id="@+id/fragment_container"
21
- android:layout_width="0dp"
22
- android:layout_height="0dp"
23
- app:layout_constraintBottom_toBottomOf="parent"
24
- app:layout_constraintEnd_toEndOf="parent"
25
- app:layout_constraintStart_toStartOf="parent"
26
- app:layout_constraintTop_toBottomOf="@id/toolbar" />
27
-
28
- </androidx.constraintlayout.widget.ConstraintLayout>
6
+ android:layout_height="match_parent" />
@@ -1,7 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <resources>
3
- <style name="ReactNativeLegalTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
4
- <item name="android:statusBarColor">?attr/colorSurface</item>
5
- <item name="android:windowBackground">?attr/colorSurface</item>
3
+ <style name="ReactNativeLegalTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
6
4
  </style>
7
5
  </resources>
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addListActivity = addListActivity;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const android_1 = require("../../../plugin-utils/build/android");
9
9
  const utils_1 = require("./utils");
10
10
  /**
11
11
  * Adds an Android Activity with list of dependencies and their licenses to project's AndroidManifest.xml
12
12
  */
13
13
  async function addListActivity(androidProjectPath) {
14
- const androidManifestPath = path_1.default.join(androidProjectPath, 'app', 'src', 'main', 'AndroidManifest.xml');
14
+ const androidManifestPath = node_path_1.default.join(androidProjectPath, 'app', 'src', 'main', 'AndroidManifest.xml');
15
15
  await (0, utils_1.modifyXMLFileContent)(androidManifestPath, (manifestObj) => {
16
16
  if (manifestObj.manifest.application?.[0]?.activity) {
17
17
  manifestObj.manifest.application[0].activity = (0, android_1.addListActivityUtil)(manifestObj.manifest.application?.[0].activity);
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Adds a file that will keep the About Libraries json resource when resource shrinking is enabled
3
+ */
4
+ export declare function addResourceKeepFile(androidProjectPath: string): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addResourceKeepFile = addResourceKeepFile;
4
+ const android_1 = require("../../../plugin-utils/build/android");
5
+ /**
6
+ * Adds a file that will keep the About Libraries json resource when resource shrinking is enabled
7
+ */
8
+ function addResourceKeepFile(androidProjectPath) {
9
+ (0, android_1.addResourceKeepFileUtil)(androidProjectPath);
10
+ }
@@ -8,6 +8,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const licenses_1 = require("@callstack/licenses");
10
10
  const addListActivity_1 = require("./addListActivity");
11
+ const addResourceKeepFile_1 = require("./addResourceKeepFile");
11
12
  const applyAndConfigureAboutLibrariesPlugin_1 = require("./applyAndConfigureAboutLibrariesPlugin");
12
13
  const declareAboutLibrariesPlugin_1 = require("./declareAboutLibrariesPlugin");
13
14
  /**
@@ -25,4 +26,5 @@ function androidCommand(androidProjectPath, scanOptionsFactory) {
25
26
  (0, declareAboutLibrariesPlugin_1.declareAboutLibrariesPlugin)(androidProjectPath);
26
27
  (0, applyAndConfigureAboutLibrariesPlugin_1.applyAndConfigureAboutLibrariesPlugin)(androidProjectPath);
27
28
  (0, addListActivity_1.addListActivity)(androidProjectPath);
29
+ (0, addResourceKeepFile_1.addResourceKeepFile)(androidProjectPath);
28
30
  }
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applyAndConfigureAboutLibrariesPlugin = applyAndConfigureAboutLibrariesPlugin;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const android_1 = require("../../../plugin-utils/build/android");
10
10
  const utils_1 = require("./utils");
11
11
  /**
@@ -14,11 +14,11 @@ const utils_1 = require("./utils");
14
14
  * NOTE: As of now, it doesn't support build.gradle.kts (Gradle Kotlin Script)
15
15
  */
16
16
  function applyAndConfigureAboutLibrariesPlugin(androidProjectPath) {
17
- if (fs_1.default.existsSync(path_1.default.join(androidProjectPath, 'app', 'build.gradle.kts'))) {
17
+ if (node_fs_1.default.existsSync(node_path_1.default.join(androidProjectPath, 'app', 'build.gradle.kts'))) {
18
18
  console.warn('Gradle Kotlin scripts are not supported yet');
19
19
  }
20
- else if (fs_1.default.existsSync(path_1.default.join(androidProjectPath, 'app', 'build.gradle'))) {
21
- (0, utils_1.modifyFileContent)(path_1.default.join(androidProjectPath, 'app', 'build.gradle'), android_1.applyAndConfigureAboutLibrariesPluginUtil);
20
+ else if (node_fs_1.default.existsSync(node_path_1.default.join(androidProjectPath, 'app', 'build.gradle'))) {
21
+ (0, utils_1.modifyFileContent)(node_path_1.default.join(androidProjectPath, 'app', 'build.gradle'), android_1.applyAndConfigureAboutLibrariesPluginUtil);
22
22
  }
23
23
  else {
24
24
  console.warn('Cannot find app/build.gradle file');
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.declareAboutLibrariesPlugin = declareAboutLibrariesPlugin;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const android_1 = require("../../../plugin-utils/build/android");
10
10
  const utils_1 = require("./utils");
11
11
  /**
@@ -14,11 +14,11 @@ const utils_1 = require("./utils");
14
14
  * NOTE: As of now, it doesn't support build.gradle.kts (Gradle Kotlin Script)
15
15
  */
16
16
  function declareAboutLibrariesPlugin(androidProjectPath) {
17
- if (fs_1.default.existsSync(path_1.default.join(androidProjectPath, 'build.gradle.kts'))) {
17
+ if (node_fs_1.default.existsSync(node_path_1.default.join(androidProjectPath, 'build.gradle.kts'))) {
18
18
  console.warn('Gradle Kotlin scripts are not supported yet');
19
19
  }
20
- else if (fs_1.default.existsSync(path_1.default.join(androidProjectPath, 'build.gradle'))) {
21
- (0, utils_1.modifyFileContent)(path_1.default.join(androidProjectPath, 'build.gradle'), android_1.declareAboutLibrariesPluginUtil);
20
+ else if (node_fs_1.default.existsSync(node_path_1.default.join(androidProjectPath, 'build.gradle'))) {
21
+ (0, utils_1.modifyFileContent)(node_path_1.default.join(androidProjectPath, 'build.gradle'), android_1.declareAboutLibrariesPluginUtil);
22
22
  }
23
23
  else {
24
24
  console.warn('Cannot find build.gradle file');
@@ -1,4 +1,4 @@
1
- import path from 'path';
1
+ import path from 'node:path';
2
2
 
3
3
  import { addListActivityUtil } from '../../../plugin-utils/build/android';
4
4
 
@@ -0,0 +1,8 @@
1
+ import { addResourceKeepFileUtil } from '../../../plugin-utils/build/android';
2
+
3
+ /**
4
+ * Adds a file that will keep the About Libraries json resource when resource shrinking is enabled
5
+ */
6
+ export function addResourceKeepFile(androidProjectPath: string) {
7
+ addResourceKeepFileUtil(androidProjectPath);
8
+ }
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import { type Types as SharedTypes, scanDependencies, writeAboutLibrariesNPMOutput } from '@callstack/licenses';
5
5
 
6
6
  import { addListActivity } from './addListActivity';
7
+ import { addResourceKeepFile } from './addResourceKeepFile';
7
8
  import { applyAndConfigureAboutLibrariesPlugin } from './applyAndConfigureAboutLibrariesPlugin';
8
9
  import { declareAboutLibrariesPlugin } from './declareAboutLibrariesPlugin';
9
10
 
@@ -29,4 +30,5 @@ export function androidCommand(androidProjectPath: string, scanOptionsFactory: S
29
30
  declareAboutLibrariesPlugin(androidProjectPath);
30
31
  applyAndConfigureAboutLibrariesPlugin(androidProjectPath);
31
32
  addListActivity(androidProjectPath);
33
+ addResourceKeepFile(androidProjectPath);
32
34
  }
@@ -1,5 +1,5 @@
1
- import fs from 'fs';
2
- import path from 'path';
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
3
 
4
4
  import { applyAndConfigureAboutLibrariesPluginUtil } from '../../../plugin-utils/build/android';
5
5
 
@@ -1,5 +1,5 @@
1
- import fs from 'fs';
2
- import path from 'path';
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
3
 
4
4
  import { declareAboutLibrariesPluginUtil } from '../../../plugin-utils/build/android';
5
5
 
@@ -2,18 +2,19 @@
2
2
  "compilerOptions": {
3
3
  "declaration": true,
4
4
  "lib": ["es2020"],
5
- "module": "commonjs",
5
+ "module": "node16",
6
6
  "target": "es2020",
7
7
 
8
8
  "strict": true,
9
9
  "esModuleInterop": true,
10
10
  "skipLibCheck": true,
11
11
  "forceConsistentCasingInFileNames": true,
12
- "moduleResolution": "node",
12
+ "moduleResolution": "node16",
13
13
 
14
14
  "outDir": "build",
15
15
  "rootDir": "src",
16
- "typeRoots": ["../types-definitions", "../../../node_modules/@types"]
16
+ "typeRoots": ["../types-definitions", "../../../node_modules/@types"],
17
+ "types": ["node", "xcode"]
17
18
  },
18
19
  "include": ["./src"],
19
20
  "exclude": ["**/__mocks__/*", "**/__tests__/*"]
@@ -1,3 +1,5 @@
1
+ import UIKit
2
+
1
3
  class ReactNativeLegalDetailViewController: UIViewController {
2
4
  private var licenseContentTextView: UITextView = {
3
5
  let textView = UITextView()