-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31308 from margelo/feat/use-attachment-gallery-ev…
…erywhere Feature: Use attachment gallery everywhere
- Loading branch information
Showing
22 changed files
with
792 additions
and
778 deletions.
There are no files selected for viewing
File renamed without changes.
62 changes: 62 additions & 0 deletions
62
patches/react-native-fast-image+8.6.3+002+bitmap-downsampling.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
diff --git a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java | ||
index 1339f5c..9dfec0c 100644 | ||
--- a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java | ||
+++ b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java | ||
@@ -176,7 +176,8 @@ class FastImageViewWithUrl extends AppCompatImageView { | ||
.apply(FastImageViewConverter | ||
.getOptions(context, imageSource, mSource) | ||
.placeholder(mDefaultSource) // show until loaded | ||
- .fallback(mDefaultSource)); // null will not be treated as error | ||
+ .fallback(mDefaultSource)) | ||
+ .transform(new ResizeTransformation()); | ||
|
||
if (key != null) | ||
builder.listener(new FastImageRequestListener(key)); | ||
diff --git a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/ResizeTransformation.java b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/ResizeTransformation.java | ||
new file mode 100644 | ||
index 0000000..1daa227 | ||
--- /dev/null | ||
+++ b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/ResizeTransformation.java | ||
@@ -0,0 +1,41 @@ | ||
+package com.dylanvann.fastimage; | ||
+ | ||
+ import android.content.Context; | ||
+ import android.graphics.Bitmap; | ||
+ | ||
+ import androidx.annotation.NonNull; | ||
+ | ||
+ import com.bumptech.glide.load.Transformation; | ||
+ import com.bumptech.glide.load.engine.Resource; | ||
+ import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; | ||
+ import com.bumptech.glide.load.resource.bitmap.BitmapResource; | ||
+ | ||
+ import java.security.MessageDigest; | ||
+ | ||
+ public class ResizeTransformation implements Transformation<Bitmap> { | ||
+ | ||
+ private final double MAX_BYTES = 25000000.0; | ||
+ | ||
+ @NonNull | ||
+ @Override | ||
+ public Resource<Bitmap> transform(@NonNull Context context, @NonNull Resource<Bitmap> resource, int outWidth, int outHeight) { | ||
+ Bitmap toTransform = resource.get(); | ||
+ | ||
+ if (toTransform.getByteCount() > MAX_BYTES) { | ||
+ double scaleFactor = Math.sqrt(MAX_BYTES / (double) toTransform.getByteCount()); | ||
+ int newHeight = (int) (outHeight * scaleFactor); | ||
+ int newWidth = (int) (outWidth * scaleFactor); | ||
+ | ||
+ BitmapPool pool = GlideApp.get(context).getBitmapPool(); | ||
+ Bitmap scaledBitmap = Bitmap.createScaledBitmap(toTransform, newWidth, newHeight, true); | ||
+ return BitmapResource.obtain(scaledBitmap, pool); | ||
+ } | ||
+ | ||
+ return resource; | ||
+ } | ||
+ | ||
+ @Override | ||
+ public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { | ||
+ messageDigest.update(("ResizeTransformation").getBytes()); | ||
+ } | ||
+ } | ||
\ No newline at end of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.