From 4a7a4b4f72bd3769d722b0f114044bc993997317 Mon Sep 17 00:00:00 2001 From: dinitri ragoo Date: Thu, 25 Apr 2024 17:32:28 +0400 Subject: [PATCH 1/6] remove spectrum --- plugin.xml | 14 -------------- src/android/SpectrumManager.java | 2 -- src/ios/SpectrumManager.h | 3 --- 3 files changed, 19 deletions(-) diff --git a/plugin.xml b/plugin.xml index 6e135ba..54aacbd 100755 --- a/plugin.xml +++ b/plugin.xml @@ -17,10 +17,6 @@ - - - - @@ -37,16 +33,6 @@ - - - - - - - - - - diff --git a/src/android/SpectrumManager.java b/src/android/SpectrumManager.java index c062e07..ae2a60e 100644 --- a/src/android/SpectrumManager.java +++ b/src/android/SpectrumManager.java @@ -5,8 +5,6 @@ import android.net.Uri; import android.os.Build; import android.util.Log; -import com.facebook.spectrum.Spectrum; -import com.facebook.spectrum.image.ImageSize; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; diff --git a/src/ios/SpectrumManager.h b/src/ios/SpectrumManager.h index 75b9122..6562c41 100644 --- a/src/ios/SpectrumManager.h +++ b/src/ios/SpectrumManager.h @@ -7,9 +7,6 @@ #import #import -#import -#import -#import NS_ASSUME_NONNULL_BEGIN @interface SpectrumManager : CDVPlugin{ From 09e99d19ba230604817128af78c52312b324bf3a Mon Sep 17 00:00:00 2001 From: dinitri ragoo Date: Thu, 25 Apr 2024 17:56:16 +0400 Subject: [PATCH 2/6] update header file --- src/ios/SpectrumManager.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ios/SpectrumManager.h b/src/ios/SpectrumManager.h index 6562c41..5596ba4 100644 --- a/src/ios/SpectrumManager.h +++ b/src/ios/SpectrumManager.h @@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN @interface SpectrumManager : CDVPlugin{ - FSPSpectrum *spectrum; } -(void)compressImage:(CDVInvokedUrlCommand*)command; @end From fb351790ea6e1d00ea77943f488b8e07cb3dd78c Mon Sep 17 00:00:00 2001 From: dinitri ragoo Date: Fri, 26 Apr 2024 15:04:56 +0400 Subject: [PATCH 3/6] import dependency and custom class --- plugin.xml | 1 + src/android/SpectrumManager.java | 1 + src/android/utils/DoNotStrip.java | 23 ++++++++++ src/android/utils/ImageSize.java | 63 ++++++++++++++++++++++++++++ src/android/utils/Preconditions.java | 54 ++++++++++++++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 src/android/utils/DoNotStrip.java create mode 100644 src/android/utils/ImageSize.java create mode 100644 src/android/utils/Preconditions.java diff --git a/plugin.xml b/plugin.xml index 54aacbd..ceaf5f1 100755 --- a/plugin.xml +++ b/plugin.xml @@ -24,6 +24,7 @@ + diff --git a/src/android/SpectrumManager.java b/src/android/SpectrumManager.java index ae2a60e..3daff12 100644 --- a/src/android/SpectrumManager.java +++ b/src/android/SpectrumManager.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.util.UUID; import androidx.exifinterface.media.ExifInterface; +import com.spoon.spectrum.utils.ImageSize; public class SpectrumManager extends CordovaPlugin { @Override diff --git a/src/android/utils/DoNotStrip.java b/src/android/utils/DoNotStrip.java new file mode 100644 index 0000000..6821004 --- /dev/null +++ b/src/android/utils/DoNotStrip.java @@ -0,0 +1,23 @@ +package com.spoon.spectrum.utils; +/* + * Copyright (c) 2004-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ + +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Add this annotation to a class, method, or field to instruct Proguard to not strip it out. + * + *

This is useful for methods called via reflection that could appear as unused to Proguard. + */ +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@Retention(CLASS) +public @interface DoNotStrip {} \ No newline at end of file diff --git a/src/android/utils/ImageSize.java b/src/android/utils/ImageSize.java new file mode 100644 index 0000000..5d29d93 --- /dev/null +++ b/src/android/utils/ImageSize.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.spoon.spectrum.utils; + +import javax.annotation.concurrent.Immutable; + +/** Represents a rectangular area defined by its width and height. */ +@DoNotStrip +@Immutable +public class ImageSize { + + /** + * Setting to 2**16 as this is the smallest common denominator for all common image libraries that + * we are interested in. + */ + @DoNotStrip static final int MAX_IMAGE_SIDE_DIMENSION = 65536; + + /** The size's width. */ + @DoNotStrip public final int width; + + /** The size's height. */ + @DoNotStrip public final int height; + + /** + * Creates a new {@link ImageSize} + * + * @param width Must be within [0, {@link #MAX_IMAGE_SIDE_DIMENSION}] + * @param height Must be within [0, {@link #MAX_IMAGE_SIDE_DIMENSION}] + */ + @DoNotStrip + public ImageSize(final int width, final int height) { + Preconditions.checkArgument(width >= 0 && width <= MAX_IMAGE_SIDE_DIMENSION); + Preconditions.checkArgument(height >= 0 && height <= MAX_IMAGE_SIDE_DIMENSION); + this.width = width; + this.height = height; + } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + final ImageSize that = (ImageSize) o; + return width == that.width && height == that.height; + } + + @Override + public int hashCode() { + int result = width; + result = 31 * result + height; + return result; + } + + @Override + public String toString() { + return "ImageSize{" + "width=" + width + ", height=" + height + '}'; + } +} diff --git a/src/android/utils/Preconditions.java b/src/android/utils/Preconditions.java new file mode 100644 index 0000000..b418a09 --- /dev/null +++ b/src/android/utils/Preconditions.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.spoon.spectrum.utils; + +import androidx.annotation.Nullable; + +/** Light-weight implementation for Precondition checks. */ +public final class Preconditions { + + private Preconditions() {} + + /** + * Asserts that the given reference is not null. + * + * @param reference A reference that might be null + * @return reference if reference is not null + * @throws NullPointerException if the given reference is null + */ + public static T checkNotNull(@Nullable final T reference) { + if (reference == null) { + throw new NullPointerException(); + } + return reference; + } + + /** + * Asserts that the given assertion about an argument is true. + * + * @param assertion The assertion to check + * @throws IllegalArgumentException if the given assertion is false + */ + public static void checkArgument(final boolean assertion) { + if (!assertion) { + throw new IllegalArgumentException(); + } + } + + /** + * Asserts that the given assertion about a state is true. + * + * @param assertion The assertion to check + * @throws IllegalStateException if the given assertion is false + */ + public static void checkState(final boolean assertion) { + if (!assertion) { + throw new IllegalStateException(); + } + } +} From 87f853d90e661d94a6fabc9aeb27d22e94652d27 Mon Sep 17 00:00:00 2001 From: dinitri ragoo Date: Fri, 26 Apr 2024 15:28:26 +0400 Subject: [PATCH 4/6] add package --- plugin.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.xml b/plugin.xml index ceaf5f1..3e13a64 100755 --- a/plugin.xml +++ b/plugin.xml @@ -21,6 +21,9 @@ + + + From f6e784f9878e769e9cd61bf5fc8999c14eaa629e Mon Sep 17 00:00:00 2001 From: dinitri ragoo Date: Fri, 26 Apr 2024 15:38:59 +0400 Subject: [PATCH 5/6] update plugin --- plugin.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.xml b/plugin.xml index 3e13a64..2b5c774 100755 --- a/plugin.xml +++ b/plugin.xml @@ -27,6 +27,9 @@ + + + From 801ab62c7f311169ede0d20849acfbf7633ce349 Mon Sep 17 00:00:00 2001 From: dinitri ragoo Date: Fri, 26 Apr 2024 15:48:01 +0400 Subject: [PATCH 6/6] fix pavkage path" --- plugin.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin.xml b/plugin.xml index 2b5c774..8f0eceb 100755 --- a/plugin.xml +++ b/plugin.xml @@ -27,9 +27,9 @@ - - - + + +