From d953b27af2e37afec374f6c927bb819d020f432f Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Tue, 4 Oct 2022 18:12:47 -0700 Subject: [PATCH 1/7] [Android][iOS] Upgrade react-native-view-shot to 3.4.0 --- .../api/viewshot/RNViewShotModule.java | 14 ++-- .../api/viewshot/RNViewShotPackage.java | 29 +++++++ .../modules/api/viewshot/ViewShot.java | 83 ++++++++++++++----- apps/bare-expo/ios/Podfile.lock | 24 +++--- apps/bare-expo/package.json | 2 +- apps/native-component-list/package.json | 2 +- .../Versioned/Core/Api/ViewShot/RNViewShot.m | 2 +- packages/expo/bundledNativeModules.json | 2 +- yarn.lock | 8 +- 9 files changed, 117 insertions(+), 49 deletions(-) create mode 100644 android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotPackage.java diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotModule.java b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotModule.java index 4dd2a1276af0e..349c162d33f5c 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotModule.java +++ b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotModule.java @@ -24,7 +24,6 @@ import java.util.Collections; import java.util.Map; -import host.exp.exponent.utils.ScopedContext; import versioned.host.exp.exponent.modules.api.viewshot.ViewShot.Formats; import versioned.host.exp.exponent.modules.api.viewshot.ViewShot.Results; @@ -33,12 +32,10 @@ public class RNViewShotModule extends ReactContextBaseJavaModule { public static final String RNVIEW_SHOT = "RNViewShot"; private final ReactApplicationContext reactContext; - private final ScopedContext mScopedContext; - public RNViewShotModule(ReactApplicationContext reactContext, ScopedContext scopedContext) { + public RNViewShotModule(ReactApplicationContext reactContext) { super(reactContext); this.reactContext = reactContext; - mScopedContext = scopedContext; } @Override @@ -84,16 +81,17 @@ public void captureRef(int tag, ReadableMap options, Promise promise) { : Formats.PNG; final double quality = options.getDouble("quality"); - final Integer scaleWidth = options.hasKey("width") ? (int) (dm.density * options.getDouble("width")) : null; - final Integer scaleHeight = options.hasKey("height") ? (int) (dm.density * options.getDouble("height")) : null; + final Integer scaleWidth = options.hasKey("width") ? options.getInt("width") : null; + final Integer scaleHeight = options.hasKey("height") ? options.getInt("height") : null; final String resultStreamFormat = options.getString("result"); final String fileName = options.hasKey("fileName") ? options.getString("fileName") : null; final Boolean snapshotContentContainer = options.getBoolean("snapshotContentContainer"); + final boolean handleGLSurfaceView = options.hasKey("handleGLSurfaceViewOnAndroid") && options.getBoolean("handleGLSurfaceViewOnAndroid"); try { File outputFile = null; if (Results.TEMP_FILE.equals(resultStreamFormat)) { - outputFile = createTempFile(mScopedContext, extension, fileName); + outputFile = createTempFile(getReactApplicationContext(), extension, fileName); } final Activity activity = getCurrentActivity(); @@ -102,7 +100,7 @@ public void captureRef(int tag, ReadableMap options, Promise promise) { uiManager.addUIBlock(new ViewShot( tag, extension, imageFormat, quality, scaleWidth, scaleHeight, outputFile, resultStreamFormat, - snapshotContentContainer, reactContext, activity, promise) + snapshotContentContainer, reactContext, activity, handleGLSurfaceView, promise) ); } catch (final Throwable ex) { Log.e(RNVIEW_SHOT, "Failed to snapshot view tag " + tag, ex); diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotPackage.java b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotPackage.java new file mode 100644 index 0000000000000..f4d0ff274c736 --- /dev/null +++ b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotPackage.java @@ -0,0 +1,29 @@ + +package versioned.host.exp.exponent.modules.api.viewshot; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; +import com.facebook.react.bridge.JavaScriptModule; +public class RNViewShotPackage implements ReactPackage { + @Override + public List createNativeModules(ReactApplicationContext reactContext) { + return Arrays.asList(new RNViewShotModule(reactContext)); + } + + // Deprecated RN 0.47 + // @Override + public List> createJSModules() { + return Collections.emptyList(); + } + + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } +} \ No newline at end of file diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/ViewShot.java b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/ViewShot.java index 938ec9bf289cc..25cff85c6f627 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/ViewShot.java +++ b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/ViewShot.java @@ -8,7 +8,8 @@ import android.graphics.Paint; import android.graphics.Point; import android.net.Uri; - +import android.os.Build; +import android.os.Handler; import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.StringDef; @@ -16,8 +17,11 @@ import android.os.Build; import android.os.Handler; import android.os.HandlerThread; +import android.os.Looper; import android.util.Base64; import android.util.Log; +import android.view.PixelCopy; +import android.view.SurfaceView; import android.view.TextureView; import android.view.View; import android.view.ViewGroup; @@ -44,6 +48,8 @@ import java.util.Locale; import java.util.Set; import java.util.WeakHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.zip.Deflater; import javax.annotation.Nullable; @@ -71,6 +77,10 @@ public class ViewShot implements UIBlock, LifecycleEventListener { * ARGB size in bytes. */ private static final int ARGB_SIZE = 4; + /** + * Wait timeout for surface view capture. + */ + private static final int SURFACE_VIEW_READ_PIXELS_TIMEOUT = 5; private HandlerThread mBgThread; private Handler mBgHandler; @@ -157,6 +167,7 @@ public void run() { private final Boolean snapshotContentContainer; @SuppressWarnings({"unused", "FieldCanBeLocal"}) private final ReactApplicationContext reactContext; + private final boolean handleGLSurfaceView; private final Activity currentActivity; //endregion @@ -174,6 +185,7 @@ public ViewShot( final Boolean snapshotContentContainer, final ReactApplicationContext reactContext, final Activity currentActivity, + final boolean handleGLSurfaceView, final Promise promise) { this.tag = tag; this.extension = extension; @@ -186,6 +198,7 @@ public ViewShot( this.snapshotContentContainer = snapshotContentContainer; this.reactContext = reactContext; this.currentActivity = currentActivity; + this.handleGLSurfaceView = handleGLSurfaceView; this.promise = promise; reactContext.addLifecycleEventListener(this); @@ -405,26 +418,54 @@ private Point captureViewImpl(@NonNull final View view, @NonNull final OutputStr for (final View child : childrenList) { // skip any child that we don't know how to process - if (!(child instanceof TextureView)) continue; - - // skip all invisible to user child views - if (child.getVisibility() != VISIBLE) continue; - - final TextureView tvChild = (TextureView) child; - tvChild.setOpaque(false); // <-- switch off background fill - - // NOTE (olku): get re-usable bitmap. TextureView should use bitmaps with matching size, - // otherwise content of the TextureView will be scaled to provided bitmap dimensions - final Bitmap childBitmapBuffer = tvChild.getBitmap(getExactBitmapForScreenshot(child.getWidth(), child.getHeight())); - - final int countCanvasSave = c.save(); - applyTransformations(c, view, child); - - // due to re-use of bitmaps for screenshot, we can get bitmap that is bigger in size than requested - c.drawBitmap(childBitmapBuffer, 0, 0, paint); - - c.restoreToCount(countCanvasSave); - recycleBitmap(childBitmapBuffer); + if (child instanceof TextureView) { + // skip all invisible to user child views + if (child.getVisibility() != VISIBLE) continue; + + final TextureView tvChild = (TextureView) child; + tvChild.setOpaque(false); // <-- switch off background fill + + // NOTE (olku): get re-usable bitmap. TextureView should use bitmaps with matching size, + // otherwise content of the TextureView will be scaled to provided bitmap dimensions + final Bitmap childBitmapBuffer = tvChild.getBitmap(getExactBitmapForScreenshot(child.getWidth(), child.getHeight())); + + final int countCanvasSave = c.save(); + applyTransformations(c, view, child); + + // due to re-use of bitmaps for screenshot, we can get bitmap that is bigger in size than requested + c.drawBitmap(childBitmapBuffer, 0, 0, paint); + + c.restoreToCount(countCanvasSave); + recycleBitmap(childBitmapBuffer); + } else if (child instanceof SurfaceView && handleGLSurfaceView) { + final SurfaceView svChild = (SurfaceView)child; + final CountDownLatch latch = new CountDownLatch(1); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + final Bitmap childBitmapBuffer = getExactBitmapForScreenshot(child.getWidth(), child.getHeight()); + try { + PixelCopy.request(svChild, childBitmapBuffer, new PixelCopy.OnPixelCopyFinishedListener() { + @Override + public void onPixelCopyFinished(int copyResult) { + final int countCanvasSave = c.save(); + applyTransformations(c, view, child); + c.drawBitmap(childBitmapBuffer, 0, 0, paint); + c.restoreToCount(countCanvasSave); + recycleBitmap(childBitmapBuffer); + latch.countDown(); + } + }, new Handler(Looper.getMainLooper())); + latch.await(SURFACE_VIEW_READ_PIXELS_TIMEOUT, TimeUnit.SECONDS); + } catch (Exception e) { + Log.e(TAG, "Cannot PixelCopy for " + svChild, e); + } + } else { + Bitmap cache = svChild.getDrawingCache(); + if (cache != null) { + c.drawBitmap(svChild.getDrawingCache(), 0, 0, paint); + } + } + } } if (width != null && height != null && (width != w || height != h)) { diff --git a/apps/bare-expo/ios/Podfile.lock b/apps/bare-expo/ios/Podfile.lock index 276a849973ea7..6e81115698493 100644 --- a/apps/bare-expo/ios/Podfile.lock +++ b/apps/bare-expo/ios/Podfile.lock @@ -1357,18 +1357,18 @@ SPEC CHECKSUMS: react-native-view-shot: da768466e1cd371de50a3a5c722d1e95456b5b2c react-native-viewpager: b99b53127d830885917ef84809c5065edd614a78 react-native-webview: d33e2db8925d090871ffeb232dfa50cb3a727581 - React-perflogger: 6009895616a455781293950bbd63d53cfc7ffbc5 - React-RCTActionSheet: 5e90aa5712af18bfc86c2c6d97d4dbe0e5451c1d - React-RCTAnimation: 50c44d6501f8bfb2fe885e544501f8798b4ff3d6 - React-RCTBlob: 3cc08e7112dd7b77faf3fa481ba22ca2bba5f20a - React-RCTImage: ca8335860b5f64c383ad27f52a28d85089d49b7a - React-RCTLinking: 297cd91bdbf427efc861fc7943e6d683e61860fa - React-RCTNetwork: 8a197bff6f1dc5353484507a4cdcd47e9356316f - React-RCTSettings: d3db1f1e61a5ad8deb50f44f5cb6c7c3ef32b3ac - React-RCTText: c2c05ab3dbfb1cf5855b14802f392148970e48da - React-RCTVibration: 89e2cbea456ac5ec623943661d00e4dc45fe74b9 - React-runtimeexecutor: 80065f60af4f4b05603661070c8622bb3740bf16 - ReactCommon: 1209130f460e4aa9d255ddc75fa0a827ebf93dfb + React-perflogger: 48c6b363e867d64b682e84f80ca45636bd65e19c + React-RCTActionSheet: 33c74fe5c754835e3715c300618da9aa2f7203fa + React-RCTAnimation: 2dbf0120d4d1ab7716079b4180f2ca89c465e46b + React-RCTBlob: ccf17363f809c5030746fdb56641527e6bf9adb7 + React-RCTImage: 88a61b23cd5a6feb8d4436f1e306d9f2ecee3462 + React-RCTLinking: c63a07ce60a6cb7642acebc80a447fb3f1872eba + React-RCTNetwork: f79b6e7c64e7317d34dec7dcfabd1279a6c1d2e7 + React-RCTSettings: 1ff0f34d41646c7942adea36ab5706320e693756 + React-RCTText: 7cb05abb91cae0ab7841d551e811ccefa3714dbd + React-RCTVibration: e9164827303fb6a5cf79e4c4af4846a09956b11f + React-runtimeexecutor: a11d0c2e14140baf1e449264ca9168ae9ae6bbd0 + ReactCommon: 7f86326b92009925c6dcf93f8e825060171c379f RNCAsyncStorage: 466b9df1a14bccda91da86e0b7d9a345d78e1673 RNCMaskedView: c298b644a10c0c142055b3ae24d83879ecb13ccd RNCPicker: 2f71e09c52ab6327e2c393213368ea0e5bfbcb65 diff --git a/apps/bare-expo/package.json b/apps/bare-expo/package.json index d6ca9ba2a7898..021c4eb149205 100644 --- a/apps/bare-expo/package.json +++ b/apps/bare-expo/package.json @@ -118,7 +118,7 @@ "react-native-screens": "~3.18.0", "react-native-shared-element": "0.8.4", "react-native-svg": "12.3.0", - "react-native-view-shot": "3.3.0", + "react-native-view-shot": "3.4.0", "react-native-webview": "11.23.1", "test-suite": "*" }, diff --git a/apps/native-component-list/package.json b/apps/native-component-list/package.json index b719f728955cf..162048d779616 100644 --- a/apps/native-component-list/package.json +++ b/apps/native-component-list/package.json @@ -155,7 +155,7 @@ "react-native-screens": "~3.18.0", "react-native-shared-element": "0.8.4", "react-native-svg": "12.3.0", - "react-native-view-shot": "3.3.0", + "react-native-view-shot": "3.4.0", "react-native-web": "~0.18.9", "react-native-webview": "11.23.1", "react-navigation": "^4.4.0", diff --git a/ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m b/ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m index eeab5934ac578..9015847eaa590 100644 --- a/ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m +++ b/ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m @@ -80,7 +80,7 @@ - (dispatch_queue_t)methodQueue reject(RCTErrorUnspecified, [NSString stringWithFormat:@"snapshotContentContainer can only be used on a RCTScrollView. instead got: %@", view], nil); return; } - RCTScrollView* rctScrollView = (RCTScrollView *)view; + RCTScrollView* rctScrollView = view; scrollView = rctScrollView.scrollView; rendered = scrollView; } diff --git a/packages/expo/bundledNativeModules.json b/packages/expo/bundledNativeModules.json index c424e3ea16c3e..cfa3fada89d93 100644 --- a/packages/expo/bundledNativeModules.json +++ b/packages/expo/bundledNativeModules.json @@ -99,7 +99,7 @@ "react-native-screens": "~3.18.0", "react-native-shared-element": "0.8.4", "react-native-svg": "12.3.0", - "react-native-view-shot": "3.3.0", + "react-native-view-shot": "3.4.0", "react-native-webview": "11.23.1", "sentry-expo": "~5.0.0", "unimodules-app-loader": "~3.1.0", diff --git a/yarn.lock b/yarn.lock index b3d33289d4a3e..e6de0b63f1a98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17305,10 +17305,10 @@ react-native-svg@12.3.0: css-select "^4.2.1" css-tree "^1.0.0-alpha.39" -react-native-view-shot@3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/react-native-view-shot/-/react-native-view-shot-3.3.0.tgz#7f0c6d2e09e5af770f5b74231a72625b379d60f8" - integrity sha512-dc3ZHCd0lvn1jtSI8bPQDta8YxzCvZ73vA8zzFH4S3TRlXLe8r5DF3wUUBlWv1p/bxbEa/A0J4kMUPeVt/v8TQ== +react-native-view-shot@3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/react-native-view-shot/-/react-native-view-shot-3.4.0.tgz#787b31b2d0525a197864e12aaea214e905e97f9a" + integrity sha512-b0CcWJGO0xLCXRsstIYRUEg/UStrR7uujQV9jFHRIVyPfBH0gRplT7Vlgimr+PX+Xg+9/rCyIKPjqK1Knv8hxg== react-native-web@~0.18.9: version "0.18.9" From 1236bb65c188164301ab20f49d8b075ab7977e49 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Tue, 4 Oct 2022 18:21:15 -0700 Subject: [PATCH 2/7] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7762ef93dde9a..b684ec5d03d9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Package-specific changes not released in any SDK will be added here just before - Updated `@react-native-picker/picker` from `2.4.0` to `2.4.2`. ([#18098](https://github.com/expo/expo/pull/18098) by [@bbarthec](https://github.com/bbarthec)) - Updated `lottie-react-native` from `5.0.1` to `5.1.3`. ([#18051](https://github.com/expo/expo/pull/18051) by [@lukmccall](https://github.com/lukmccall)) - Updated `react-native-view-shot` from `3.1.2` to `3.3.0`. ([#18050](https://github.com/expo/expo/pull/18050) by [@lukmccall](https://github.com/lukmccall)) +- Updated `react-native-view-shot` from `3.3.0` to `3.4.0`. ([#19405](https://github.com/expo/expo/pull/19405) by [@douglowder](https://github.com/douglowder)) - Updated `react-native-maps` from `0.30.2` to `0.31.1`. ([#18052](https://github.com/expo/expo/pull/18052) by [@lukmccall](https://github.com/lukmccall)) - Updated `@react-native-community/netinfo` from `8.2.0` to `9.1.0`. ([#18045](https://github.com/expo/expo/pull/18045) by [@lukmccall](https://github.com/lukmccall)) - Updated `react-native-webview` from `11.18.1` to `11.23.0`. ([#18047](https://github.com/expo/expo/pull/18047) by [@lukmccall](https://github.com/lukmccall)) From c55d612438f06b012379798585378be25fa4c854 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Wed, 5 Oct 2022 10:22:58 -0700 Subject: [PATCH 3/7] Fix CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b684ec5d03d9d..1d5494bf50829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Package-specific changes not released in any SDK will be added here just before - Updated `@stripe/stripe-react-native` from `0.13.1` to `0.18.1` on iOS. ([#19055](https://github.com/expo/expo/pull/19055) by [@tsapeta](https://github.com/tsapeta)) - Updated `@shopify/flash-list` from `1.1.0` to `1.3.0`. ([#19317](https://github.com/expo/expo/pull/19317) by [@kudo](https://github.com/kudo)) +- Updated `react-native-view-shot` from `3.3.0` to `3.4.0`. ([#19405](https://github.com/expo/expo/pull/19405) by [@douglowder](https://github.com/douglowder)) - Updated `react-native-webview` from `11.23.0` to `11.23.1`. ([#19375](https://github.com/expo/expo/pull/19375) by [@aleqsio](https://github.com/aleqsio)) - Updated `react-native-gesture-handler` from `2.5.0` to `2.7.0`. ([#19362](https://github.com/expo/expo/pull/19362) by [@tsapeta](https://github.com/tsapeta)) - Updated `@react-native-picker/picker` from `2.4.2` to `2.4.6`. ([#19390](https://github.com/expo/expo/pull/19390) by [@aleqsio](https://github.com/aleqsio)) @@ -31,7 +32,6 @@ Package-specific changes not released in any SDK will be added here just before - Updated `@react-native-picker/picker` from `2.4.0` to `2.4.2`. ([#18098](https://github.com/expo/expo/pull/18098) by [@bbarthec](https://github.com/bbarthec)) - Updated `lottie-react-native` from `5.0.1` to `5.1.3`. ([#18051](https://github.com/expo/expo/pull/18051) by [@lukmccall](https://github.com/lukmccall)) - Updated `react-native-view-shot` from `3.1.2` to `3.3.0`. ([#18050](https://github.com/expo/expo/pull/18050) by [@lukmccall](https://github.com/lukmccall)) -- Updated `react-native-view-shot` from `3.3.0` to `3.4.0`. ([#19405](https://github.com/expo/expo/pull/19405) by [@douglowder](https://github.com/douglowder)) - Updated `react-native-maps` from `0.30.2` to `0.31.1`. ([#18052](https://github.com/expo/expo/pull/18052) by [@lukmccall](https://github.com/lukmccall)) - Updated `@react-native-community/netinfo` from `8.2.0` to `9.1.0`. ([#18045](https://github.com/expo/expo/pull/18045) by [@lukmccall](https://github.com/lukmccall)) - Updated `react-native-webview` from `11.18.1` to `11.23.0`. ([#18047](https://github.com/expo/expo/pull/18047) by [@lukmccall](https://github.com/lukmccall)) From 4fee1a60c6103bc44e5b3a5ac3437044c9a11480 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Wed, 5 Oct 2022 12:21:49 -0700 Subject: [PATCH 4/7] Restore fix in RNViewShot.m --- ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m b/ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m index 9015847eaa590..eeab5934ac578 100644 --- a/ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m +++ b/ios/Exponent/Versioned/Core/Api/ViewShot/RNViewShot.m @@ -80,7 +80,7 @@ - (dispatch_queue_t)methodQueue reject(RCTErrorUnspecified, [NSString stringWithFormat:@"snapshotContentContainer can only be used on a RCTScrollView. instead got: %@", view], nil); return; } - RCTScrollView* rctScrollView = view; + RCTScrollView* rctScrollView = (RCTScrollView *)view; scrollView = rctScrollView.scrollView; rendered = scrollView; } From 43dc5c22c9b71508b833b859ec197aed573057a3 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Wed, 5 Oct 2022 13:31:36 -0700 Subject: [PATCH 5/7] Restore Expo changes to RNViewShotModules.java --- .../exponent/modules/api/viewshot/RNViewShotModule.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotModule.java b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotModule.java index 349c162d33f5c..0df298f679805 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotModule.java +++ b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotModule.java @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.Map; +import host.exp.exponent.utils.ScopedContext; import versioned.host.exp.exponent.modules.api.viewshot.ViewShot.Formats; import versioned.host.exp.exponent.modules.api.viewshot.ViewShot.Results; @@ -32,10 +33,12 @@ public class RNViewShotModule extends ReactContextBaseJavaModule { public static final String RNVIEW_SHOT = "RNViewShot"; private final ReactApplicationContext reactContext; + private final ScopedContext mScopedContext; - public RNViewShotModule(ReactApplicationContext reactContext) { + public RNViewShotModule(ReactApplicationContext reactContext, ScopedContext scopedContext) { super(reactContext); this.reactContext = reactContext; + mScopedContext = scopedContext; } @Override @@ -91,7 +94,7 @@ public void captureRef(int tag, ReadableMap options, Promise promise) { try { File outputFile = null; if (Results.TEMP_FILE.equals(resultStreamFormat)) { - outputFile = createTempFile(getReactApplicationContext(), extension, fileName); + outputFile = createTempFile(mScopedContext, extension, fileName); } final Activity activity = getCurrentActivity(); From 41cad2a0bef24e8cd4c738404527052c241bf976 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Wed, 5 Oct 2022 16:35:41 -0700 Subject: [PATCH 6/7] Update bare-expo Podfile.lock --- apps/bare-expo/ios/Podfile.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/bare-expo/ios/Podfile.lock b/apps/bare-expo/ios/Podfile.lock index 6e81115698493..0c46043babfee 100644 --- a/apps/bare-expo/ios/Podfile.lock +++ b/apps/bare-expo/ios/Podfile.lock @@ -634,7 +634,7 @@ PODS: - React-Core - react-native-slider (4.2.3): - React-Core - - react-native-view-shot (3.3.0): + - react-native-view-shot (3.4.0): - React-Core - react-native-viewpager (5.0.11): - React-Core @@ -1354,21 +1354,21 @@ SPEC CHECKSUMS: react-native-safe-area-context: 6c12e3859b6f27b25de4fee8201cfb858432d8de react-native-segmented-control: 06607462630512ff8eef652ec560e6235a30cc3e react-native-slider: 98b724cd3e44c3454a6d0724e796d4e9c52189ce - react-native-view-shot: da768466e1cd371de50a3a5c722d1e95456b5b2c + react-native-view-shot: a60a98a18c72bcaaaf2138f9aab960ae9b0d96c7 react-native-viewpager: b99b53127d830885917ef84809c5065edd614a78 react-native-webview: d33e2db8925d090871ffeb232dfa50cb3a727581 - React-perflogger: 48c6b363e867d64b682e84f80ca45636bd65e19c - React-RCTActionSheet: 33c74fe5c754835e3715c300618da9aa2f7203fa - React-RCTAnimation: 2dbf0120d4d1ab7716079b4180f2ca89c465e46b - React-RCTBlob: ccf17363f809c5030746fdb56641527e6bf9adb7 - React-RCTImage: 88a61b23cd5a6feb8d4436f1e306d9f2ecee3462 - React-RCTLinking: c63a07ce60a6cb7642acebc80a447fb3f1872eba - React-RCTNetwork: f79b6e7c64e7317d34dec7dcfabd1279a6c1d2e7 - React-RCTSettings: 1ff0f34d41646c7942adea36ab5706320e693756 - React-RCTText: 7cb05abb91cae0ab7841d551e811ccefa3714dbd - React-RCTVibration: e9164827303fb6a5cf79e4c4af4846a09956b11f - React-runtimeexecutor: a11d0c2e14140baf1e449264ca9168ae9ae6bbd0 - ReactCommon: 7f86326b92009925c6dcf93f8e825060171c379f + React-perflogger: 6009895616a455781293950bbd63d53cfc7ffbc5 + React-RCTActionSheet: 5e90aa5712af18bfc86c2c6d97d4dbe0e5451c1d + React-RCTAnimation: 50c44d6501f8bfb2fe885e544501f8798b4ff3d6 + React-RCTBlob: 3cc08e7112dd7b77faf3fa481ba22ca2bba5f20a + React-RCTImage: ca8335860b5f64c383ad27f52a28d85089d49b7a + React-RCTLinking: 297cd91bdbf427efc861fc7943e6d683e61860fa + React-RCTNetwork: 8a197bff6f1dc5353484507a4cdcd47e9356316f + React-RCTSettings: d3db1f1e61a5ad8deb50f44f5cb6c7c3ef32b3ac + React-RCTText: c2c05ab3dbfb1cf5855b14802f392148970e48da + React-RCTVibration: 89e2cbea456ac5ec623943661d00e4dc45fe74b9 + React-runtimeexecutor: 80065f60af4f4b05603661070c8622bb3740bf16 + ReactCommon: 1209130f460e4aa9d255ddc75fa0a827ebf93dfb RNCAsyncStorage: 466b9df1a14bccda91da86e0b7d9a345d78e1673 RNCMaskedView: c298b644a10c0c142055b3ae24d83879ecb13ccd RNCPicker: 2f71e09c52ab6327e2c393213368ea0e5bfbcb65 From 1ba030c5171d329cc911feb1eb388d1ba2604ba6 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Thu, 6 Oct 2022 09:39:31 -0700 Subject: [PATCH 7/7] Remove unused RNViewShotPackage.java --- .../api/viewshot/RNViewShotPackage.java | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotPackage.java diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotPackage.java b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotPackage.java deleted file mode 100644 index f4d0ff274c736..0000000000000 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/viewshot/RNViewShotPackage.java +++ /dev/null @@ -1,29 +0,0 @@ - -package versioned.host.exp.exponent.modules.api.viewshot; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import com.facebook.react.ReactPackage; -import com.facebook.react.bridge.NativeModule; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.uimanager.ViewManager; -import com.facebook.react.bridge.JavaScriptModule; -public class RNViewShotPackage implements ReactPackage { - @Override - public List createNativeModules(ReactApplicationContext reactContext) { - return Arrays.asList(new RNViewShotModule(reactContext)); - } - - // Deprecated RN 0.47 - // @Override - public List> createJSModules() { - return Collections.emptyList(); - } - - @Override - public List createViewManagers(ReactApplicationContext reactContext) { - return Collections.emptyList(); - } -} \ No newline at end of file