Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove spectrum #15

Merged
merged 6 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@

<!-- android -->
<platform name="android">
<framework src="com.facebook.spectrum:spectrum-default:1.3.0" />
<framework src="com.facebook.spectrum:spectrum-core:1.3.0" />
<framework src="com.facebook.spectrum:spectrum-jpeg:1.3.0" />
<framework src="com.facebook.spectrum:spectrum-png:1.3.0" />
<config-file target="res/xml/config.xml" parent="/*">
<feature name="SpectrumManager">
<param name="android-package" value="com.spoon.spectrum.SpectrumManager" />
</feature>
<feature name="ImageSize">
<param name="android-package" value="com.spoon.spectrum.utils.ImageSize" />
</feature>
</config-file>
<source-file src="src/android/SpectrumManager.java" target-dir="src/com/spoon/spectrum" />
<source-file src="src/android/SpoonCameraExif.java" target-dir="src/com/spoon/spectrum" />
<source-file src="src/android/utils/ImageSize.java" target-dir="src/com/spoon/spectrum/utils" />
<source-file src="src/android/utils/DoNotStrip.java" target-dir="src/com/spoon/spectrum/utils" />
<source-file src="src/android/utils/Preconditions.java" target-dir="src/com/spoon/spectrum/utils" />
<framework src="com.google.code.findbugs:jsr305:3.0.2"></framework>
</platform>

<!-- ios -->
Expand All @@ -37,16 +40,6 @@
<param name="ios-package" value="SpectrumManager" />
</feature>
</config-file>
<podspec>
<config>
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods>
<pod name="SpectrumKit/Base" spec="~> 1.2.0" />
<pod name="SpectrumKit/Plugins/Jpeg" spec="~> 1.2.0" />
<pod name="SpectrumKit/Plugins/Png" spec="~> 1.2.0" />
</pods>
</podspec>
<header-file src="src/ios/SpectrumManager.h" />
<source-file src="src/ios/SpectrumManager.m" />
</platform>
Expand Down
3 changes: 1 addition & 2 deletions src/android/SpectrumManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,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
Expand Down
23 changes: 23 additions & 0 deletions src/android/utils/DoNotStrip.java
Original file line number Diff line number Diff line change
@@ -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.
*
* <p>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 {}
63 changes: 63 additions & 0 deletions src/android/utils/ImageSize.java
Original file line number Diff line number Diff line change
@@ -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 + '}';
}
}
54 changes: 54 additions & 0 deletions src/android/utils/Preconditions.java
Original file line number Diff line number Diff line change
@@ -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 <code>null</code>
* @throws NullPointerException if the given reference is <code>null</code>
*/
public static <T> 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 <code>false</code>
*/
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 <code>false</code>
*/
public static void checkState(final boolean assertion) {
if (!assertion) {
throw new IllegalStateException();
}
}
}
4 changes: 0 additions & 4 deletions src/ios/SpectrumManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@

#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>
#import <SpectrumKit/SpectrumKit.h>
#import <SpectrumKit/FSPJpegPlugin.h>
#import <SpectrumKit/FSPPngPlugin.h>
NS_ASSUME_NONNULL_BEGIN

@interface SpectrumManager : CDVPlugin{
FSPSpectrum *spectrum;
}
-(void)compressImage:(CDVInvokedUrlCommand*)command;
@end
Expand Down
Loading