expo-screen-capture 5.1.1 → 5.3.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.
- package/CHANGELOG.md +16 -0
- package/README.md +4 -4
- package/android/build.gradle +8 -10
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/expo/modules/screencapture/ScreenCaptureModule.kt +22 -60
- package/android/src/main/java/expo/modules/screencapture/ScreenShotEventEmitter.kt +7 -4
- package/build/ExpoScreenCapture.d.ts +1 -1
- package/build/ExpoScreenCapture.d.ts.map +1 -1
- package/build/ExpoScreenCapture.js +2 -2
- package/build/ExpoScreenCapture.js.map +1 -1
- package/expo-module.config.json +7 -0
- package/package.json +2 -2
- package/src/ExpoScreenCapture.ts +2 -3
- package/android/src/main/java/expo/modules/screencapture/ScreenCapturePackage.kt +0 -12
- package/unimodule.json +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,22 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 5.3.0 — 2023-06-21
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fixed Android build warnings for Gradle version 8. ([#22537](https://github.com/expo/expo/pull/22537), [#22609](https://github.com/expo/expo/pull/22609) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
19
|
+
## 5.2.0 — 2023-05-08
|
|
20
|
+
|
|
21
|
+
### 🎉 New features
|
|
22
|
+
|
|
23
|
+
- On Android, migrated to Expo Modules API. ([#22208](https://github.com/expo/expo/pull/22208) by [@alanjhughes](https://github.com/alanjhughes))
|
|
24
|
+
|
|
25
|
+
### 💡 Others
|
|
26
|
+
|
|
27
|
+
- Android: Switch from deprecated `toLowerCase` to `lowercase` function ([#22225](https://github.com/expo/expo/pull/22225) by [@hbiede](https://github.com/hbiede))
|
|
28
|
+
|
|
13
29
|
## 5.1.1 — 2023-02-09
|
|
14
30
|
|
|
15
31
|
_This version does not introduce any user-facing changes._
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ This is especially important on Android, since the [`android.media.projection`](
|
|
|
13
13
|
|
|
14
14
|
## Installation in managed Expo projects
|
|
15
15
|
|
|
16
|
-
For [managed](https://docs.expo.dev/
|
|
16
|
+
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/screen-capture/).
|
|
17
17
|
|
|
18
18
|
## Installation in bare React Native projects
|
|
19
19
|
|
|
@@ -21,13 +21,13 @@ For bare React Native projects, you must ensure that you have [installed and con
|
|
|
21
21
|
|
|
22
22
|
### Add the package to your npm dependencies
|
|
23
23
|
|
|
24
|
-
```
|
|
25
|
-
expo install expo-screen-capture
|
|
24
|
+
```
|
|
25
|
+
npx expo install expo-screen-capture
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
### Configure for iOS
|
|
29
29
|
|
|
30
|
-
```
|
|
30
|
+
```
|
|
31
31
|
npx pod-install
|
|
32
32
|
```
|
|
33
33
|
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '5.
|
|
6
|
+
version = '5.3.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -35,19 +35,11 @@ buildscript {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// Creating sources with comments
|
|
39
|
-
task androidSourcesJar(type: Jar) {
|
|
40
|
-
classifier = 'sources'
|
|
41
|
-
from android.sourceSets.main.java.srcDirs
|
|
42
|
-
}
|
|
43
|
-
|
|
44
38
|
afterEvaluate {
|
|
45
39
|
publishing {
|
|
46
40
|
publications {
|
|
47
41
|
release(MavenPublication) {
|
|
48
42
|
from components.release
|
|
49
|
-
// Add additional sourcesJar to artifacts
|
|
50
|
-
artifact(androidSourcesJar)
|
|
51
43
|
}
|
|
52
44
|
}
|
|
53
45
|
repositories {
|
|
@@ -70,15 +62,21 @@ android {
|
|
|
70
62
|
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
71
63
|
}
|
|
72
64
|
|
|
65
|
+
namespace "expo.modules.screencapture"
|
|
73
66
|
defaultConfig {
|
|
74
67
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
68
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
76
69
|
versionCode 7
|
|
77
|
-
versionName '5.
|
|
70
|
+
versionName '5.3.0'
|
|
78
71
|
}
|
|
79
72
|
lintOptions {
|
|
80
73
|
abortOnError false
|
|
81
74
|
}
|
|
75
|
+
publishing {
|
|
76
|
+
singleVariant("release") {
|
|
77
|
+
withSourcesJar()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
repositories {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<manifest
|
|
1
|
+
<manifest>
|
|
2
2
|
</manifest>
|
|
@@ -1,69 +1,31 @@
|
|
|
1
1
|
package expo.modules.screencapture
|
|
2
2
|
|
|
3
|
-
import android.app.Activity
|
|
4
3
|
import android.content.Context
|
|
5
4
|
import android.view.WindowManager
|
|
6
|
-
|
|
7
|
-
import expo.modules.
|
|
8
|
-
import expo.modules.
|
|
9
|
-
import expo.modules.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
override fun onCreate(moduleRegistry: ModuleRegistry) {
|
|
23
|
-
mActivityProvider = moduleRegistry.getModule(ActivityProvider::class.java)
|
|
24
|
-
ScreenshotEventEmitter(context, moduleRegistry)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@ExpoMethod
|
|
28
|
-
fun preventScreenCapture(promise: Promise) {
|
|
29
|
-
val activity = getCurrentActivity()
|
|
30
|
-
|
|
31
|
-
activity.runOnUiThread {
|
|
32
|
-
try {
|
|
33
|
-
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
|
34
|
-
} catch (exception: Exception) {
|
|
35
|
-
promise.reject(ERROR_CODE_PREVENTION, "Failed to prevent screen capture: " + exception)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
promise.resolve(null)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@ExpoMethod
|
|
42
|
-
fun allowScreenCapture(promise: Promise) {
|
|
43
|
-
val activity = getCurrentActivity()
|
|
44
|
-
|
|
45
|
-
activity.runOnUiThread {
|
|
46
|
-
try {
|
|
47
|
-
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
|
48
|
-
} catch (exception: Exception) {
|
|
49
|
-
promise.reject(ERROR_CODE_PREVENTION, "Failed to reallow screen capture: " + exception)
|
|
50
|
-
}
|
|
5
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
6
|
+
import expo.modules.kotlin.functions.Queues
|
|
7
|
+
import expo.modules.kotlin.modules.Module
|
|
8
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
9
|
+
|
|
10
|
+
class ScreenCaptureModule : Module() {
|
|
11
|
+
private val context: Context
|
|
12
|
+
get() = appContext.reactContext ?: throw Exceptions.AppContextLost()
|
|
13
|
+
private val currentActivity
|
|
14
|
+
get() = appContext.currentActivity ?: throw Exceptions.MissingActivity()
|
|
15
|
+
|
|
16
|
+
override fun definition() = ModuleDefinition {
|
|
17
|
+
Name("ExpoScreenCapture")
|
|
18
|
+
|
|
19
|
+
OnCreate {
|
|
20
|
+
ScreenshotEventEmitter(context, appContext.legacyModuleRegistry)
|
|
51
21
|
}
|
|
52
|
-
promise.resolve(null)
|
|
53
|
-
}
|
|
54
22
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (activity != null) {
|
|
59
|
-
return activity
|
|
60
|
-
} else {
|
|
61
|
-
throw CurrentActivityNotFoundException()
|
|
62
|
-
}
|
|
63
|
-
}
|
|
23
|
+
AsyncFunction("preventScreenCapture") {
|
|
24
|
+
currentActivity.window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
|
25
|
+
}.runOnQueue(Queues.MAIN)
|
|
64
26
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
27
|
+
AsyncFunction("allowScreenCapture") {
|
|
28
|
+
currentActivity.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
|
29
|
+
}.runOnQueue(Queues.MAIN)
|
|
68
30
|
}
|
|
69
31
|
}
|
|
@@ -7,6 +7,7 @@ import android.database.ContentObserver
|
|
|
7
7
|
import android.net.Uri
|
|
8
8
|
import android.os.Bundle
|
|
9
9
|
import android.os.Handler
|
|
10
|
+
import android.os.Looper
|
|
10
11
|
import android.provider.MediaStore
|
|
11
12
|
import android.util.Log
|
|
12
13
|
|
|
@@ -30,7 +31,7 @@ class ScreenshotEventEmitter(val context: Context, moduleRegistry: ModuleRegistr
|
|
|
30
31
|
moduleRegistry.getModule(UIManager::class.java).registerLifecycleEventListener(this)
|
|
31
32
|
eventEmitter = moduleRegistry.getModule(EventEmitter::class.java)
|
|
32
33
|
|
|
33
|
-
val contentObserver: ContentObserver = object : ContentObserver(Handler()) {
|
|
34
|
+
val contentObserver: ContentObserver = object : ContentObserver(Handler(Looper.getMainLooper())) {
|
|
34
35
|
override fun onChange(selfChange: Boolean, uri: Uri?) {
|
|
35
36
|
super.onChange(selfChange, uri)
|
|
36
37
|
if (isListening) {
|
|
@@ -65,14 +66,16 @@ class ScreenshotEventEmitter(val context: Context, moduleRegistry: ModuleRegistr
|
|
|
65
66
|
return ContextCompat.checkSelfPermission(context, permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
@Nullable
|
|
69
|
+
@Nullable
|
|
70
|
+
private fun getFilePathFromContentResolver(context: Context, uri: Uri?): String? {
|
|
69
71
|
if (uri == null) {
|
|
70
72
|
return null
|
|
71
73
|
}
|
|
72
74
|
try {
|
|
73
75
|
val cursor = context.contentResolver.query(uri, arrayOf(MediaStore.Images.Media.DATA), null, null, null)
|
|
74
76
|
if (cursor != null && cursor.moveToFirst()) {
|
|
75
|
-
val
|
|
77
|
+
val index = cursor.getColumnIndex(MediaStore.Images.Media.DATA)
|
|
78
|
+
val path = cursor.getString(index)
|
|
76
79
|
cursor.close()
|
|
77
80
|
return path
|
|
78
81
|
}
|
|
@@ -83,7 +86,7 @@ class ScreenshotEventEmitter(val context: Context, moduleRegistry: ModuleRegistr
|
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
private fun isPathOfNewScreenshot(path: String): Boolean {
|
|
86
|
-
if (!path.
|
|
89
|
+
if (!path.lowercase().contains("screenshot")) {
|
|
87
90
|
return false
|
|
88
91
|
}
|
|
89
92
|
// Cannot check that the onChange event is for an insert operation until API level 30
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoScreenCapture.d.ts","sourceRoot":"","sources":["../src/ExpoScreenCapture.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ExpoScreenCapture.d.ts","sourceRoot":"","sources":["../src/ExpoScreenCapture.ts"],"names":[],"mappings":";AACA,wBAAwD"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
export default requireNativeModule('ExpoScreenCapture');
|
|
3
3
|
//# sourceMappingURL=ExpoScreenCapture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoScreenCapture.js","sourceRoot":"","sources":["../src/ExpoScreenCapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ExpoScreenCapture.js","sourceRoot":"","sources":["../src/ExpoScreenCapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,eAAe,mBAAmB,CAAC,mBAAmB,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\nexport default requireNativeModule('ExpoScreenCapture');\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-screen-capture",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "ExpoScreenCapture standalone module",
|
|
5
5
|
"main": "build/ScreenCapture.js",
|
|
6
6
|
"types": "build/ScreenCapture.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"expo": "*"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "fa5ecca8251986b9f197cc14074eec0ab6dfb6db"
|
|
43
43
|
}
|
package/src/ExpoScreenCapture.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export default NativeModulesProxy.ExpoScreenCapture;
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
export default requireNativeModule('ExpoScreenCapture');
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
package expo.modules.screencapture
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
|
|
5
|
-
import expo.modules.core.BasePackage
|
|
6
|
-
import expo.modules.core.ExportedModule
|
|
7
|
-
|
|
8
|
-
class ScreenCapturePackage : BasePackage() {
|
|
9
|
-
override fun createExportedModules(context: Context): List<ExportedModule> {
|
|
10
|
-
return listOf(ScreenCaptureModule(context) as ExportedModule)
|
|
11
|
-
}
|
|
12
|
-
}
|
package/unimodule.json
DELETED