Skip to content

Commit

Permalink
feat: Capacitor 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
dtarnawsky committed Apr 16, 2024
1 parent b90457a commit 935f035
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 1,873 deletions.
12 changes: 6 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.10.0'
androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.12.0'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
}

buildscript {
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.8.20'
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.android.tools.build:gradle:8.2.1'
classpath 'com.google.gms:google-services:4.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,10 +26,10 @@ apply plugin: 'kotlin-kapt'

android {
namespace "com.capacitorcommunity.CapacitorOcr"
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
versionCode 2
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
7 changes: 3 additions & 4 deletions ios/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class TextDetector {
var orientation: CGImagePropertyOrientation
var detectedAlready = false


public init(call: CAPPluginCall, image: UIImage) {
self.call = call
self.image = image
Expand All @@ -43,7 +42,7 @@ public class TextDetector {
guard !detectedAlready else {
self.call.reject("An image has already been processed for text. Please instantiate a new TextDetector object.")
return
}
}
self.detectedAlready = true

guard let cgImage = image.cgImage else {
Expand All @@ -60,11 +59,11 @@ public class TextDetector {
}

// VNImageRequestHandler processes image analysis requests on a single image.
let imageRequestHandler = VNImageRequestHandler(cgImage: cgImage,orientation: orientation, options: [:])
let imageRequestHandler = VNImageRequestHandler(cgImage: cgImage, orientation: orientation, options: [:])

DispatchQueue.global(qos: .userInitiated).async {
do {
try imageRequestHandler.perform([self.textDetectionRequest])
try imageRequestHandler.perform([self.textDetectionRequest])
} catch let error as NSError {
print("Failed to perform image request: \(error)")
self.call.reject(error.description)
Expand Down
16 changes: 8 additions & 8 deletions ios/PluginTests/PluginTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ import Capacitor
@testable import Plugin

class PluginTests: XCTestCase {

override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}

func testEcho() {
// This is an example of a functional test case for a plugin.
// Use XCTAssert and related functions to verify your tests produce the correct results.

let value = "Hello, World!"
let plugin = MyPlugin()

let call = CAPPluginCall(callbackId: "test", options: [
"value": value
], success: { (result, call) in
], success: { (result, _) in
let resultValue = result!.data["value"] as? String
XCTAssertEqual(value, resultValue)
}, error: { (err) in
}, error: { (_) in
XCTFail("Error shouldn't have been called")
})

plugin.echo(call!)
}
}
Loading

0 comments on commit 935f035

Please sign in to comment.