diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 914e7a868..00ea882a7 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libopencv_core.a b/app/src/main/jniLibs/armeabi-v7a/libopencv_core.a deleted file mode 100644 index 2e4032e9d..000000000 Binary files a/app/src/main/jniLibs/armeabi-v7a/libopencv_core.a and /dev/null differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libopencv_imgproc.a b/app/src/main/jniLibs/armeabi-v7a/libopencv_imgproc.a deleted file mode 100644 index f4f66b703..000000000 Binary files a/app/src/main/jniLibs/armeabi-v7a/libopencv_imgproc.a and /dev/null differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libopencv_java3.so b/app/src/main/jniLibs/armeabi-v7a/libopencv_java3.so new file mode 100644 index 000000000..38f1ba4f9 Binary files /dev/null and b/app/src/main/jniLibs/armeabi-v7a/libopencv_java3.so differ diff --git a/autojs/build.gradle b/autojs/build.gradle index 58a0a2b94..4fec15589 100644 --- a/autojs/build.gradle +++ b/autojs/build.gradle @@ -49,11 +49,12 @@ dependencies { }) api 'com.google.android.material:material:1.1.0-alpha01' api 'com.github.hyb1996:EnhancedFloaty:0.31' - api 'com.github.hyb1996:OpenCvLib:2.4.13.4-imgproc' api 'com.makeramen:roundedimageview:2.3.0' + // OpenCv + api(name: 'opencv-3.4.3', ext: 'aar') // OkHttp api 'com.squareup.okhttp3:okhttp:3.10.0' - //JDeferred + // JDeferred api 'org.jdeferred:jdeferred-android-aar:1.2.6' //RootShell api 'com.github.Stericson:RootShell:1.6' diff --git a/autojs/src/main/java/com/stardust/autojs/core/image/ImageWrapper.java b/autojs/src/main/java/com/stardust/autojs/core/image/ImageWrapper.java index 358d9771d..a260785ee 100644 --- a/autojs/src/main/java/com/stardust/autojs/core/image/ImageWrapper.java +++ b/autojs/src/main/java/com/stardust/autojs/core/image/ImageWrapper.java @@ -4,19 +4,20 @@ import android.graphics.Color; import android.media.Image; import android.os.Build; -import androidx.annotation.RequiresApi; +import com.stardust.autojs.core.opencv.Mat; import com.stardust.autojs.core.opencv.OpenCVHelper; import com.stardust.pio.UncheckedIOException; import org.opencv.android.Utils; -import com.stardust.autojs.core.opencv.Mat; -import org.opencv.highgui.Highgui; +import org.opencv.imgcodecs.Imgcodecs; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.nio.ByteBuffer; +import androidx.annotation.RequiresApi; + /** * Created by Stardust on 2017/11/25. */ @@ -117,7 +118,7 @@ public void saveTo(String path) { throw new UncheckedIOException(e); } } else { - Highgui.imwrite(path, mMat); + Imgcodecs.imwrite(path, mMat); } } diff --git a/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java b/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java index 065f50a3f..14c290d1d 100644 --- a/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java +++ b/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java @@ -214,7 +214,7 @@ private static void getBestMatched(Mat tmResult, Mat template, int matchMethod, break; } outResult.add(bestMatched); - Core.rectangle(tmResult, bestMatched.point, + Imgproc.rectangle(tmResult, bestMatched.point, new Point(bestMatched.point.x + template.cols(), bestMatched.point.y + template.rows()), new Scalar(0, 255, 0), -1); } diff --git a/autojs/src/main/java/com/stardust/autojs/core/opencv/OpenCVHelper.java b/autojs/src/main/java/com/stardust/autojs/core/opencv/OpenCVHelper.java index 05afece41..531091b3d 100644 --- a/autojs/src/main/java/com/stardust/autojs/core/opencv/OpenCVHelper.java +++ b/autojs/src/main/java/com/stardust/autojs/core/opencv/OpenCVHelper.java @@ -1,7 +1,10 @@ package com.stardust.autojs.core.opencv; import android.content.Context; + import androidx.annotation.Nullable; + +import android.os.Looper; import android.util.Log; import com.afollestad.materialdialogs.MaterialDialog; @@ -25,7 +28,7 @@ public interface InitializeCallback { private static final String LOG_TAG = "OpenCVHelper"; private static boolean sInitialized = false; - public static MatOfPoint newMatOfPoint(Mat mat){ + public static MatOfPoint newMatOfPoint(Mat mat) { return new MatOfPoint(mat); } @@ -51,97 +54,14 @@ public synchronized static void initIfNeeded(Context context, InitializeCallback return; } sInitialized = true; - OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_13, context.getApplicationContext(), new LoaderCallback(context) { - - @Override - protected void finish() { + if (Looper.getMainLooper() == Looper.myLooper()) { + new Thread(() -> { + OpenCVLoader.initDebug(); callback.onInitFinish(); - } - }); - } - - - public static class LoaderCallback implements LoaderCallbackInterface { - private Context mContext; - - public LoaderCallback(Context context) { - this.mContext = context; - } - - public void onManagerConnected(int status) { - switch (status) { - case 0: - finish(); - break; - case 1: - default: - Log.e(LOG_TAG, "OpenCV loading failed!"); - DialogUtils.showDialog(new MaterialDialog.Builder(mContext) - .title("OpenCV error") - .content("OpenCV was not initialised correctly. Application will be shut down") - .cancelable(false) - .positiveText("OK") - .onPositive((dialog, which) -> finish()) - .build()); - break; - case 2: - Log.e(LOG_TAG, "Package installation failed!"); - DialogUtils.showDialog(new MaterialDialog.Builder(mContext) - .title("OpenCV Manager") - .content("Package installation failed!") - .cancelable(false) - .positiveText("OK") - .onPositive((dialog, which) -> finish()) - .build()); - break; - case 3: - Log.d(LOG_TAG, "OpenCV library instalation was canceled by user"); - finish(); - break; - case 4: - Log.d(LOG_TAG, "OpenCV Manager Service is uncompatible with this app!"); - DialogUtils.showDialog(new MaterialDialog.Builder(mContext) - .title("OpenCV Manager") - .content("OpenCV Manager service is incompatible with this app. Try to update it via Google Play.") - .cancelable(false) - .positiveText("OK") - .onPositive((dialog, which) -> finish()) - .build()); - } - - } - - public void onPackageInstall(int operation, final InstallCallbackInterface callback) { - switch (operation) { - case 0: - DialogUtils.showDialog(new MaterialDialog.Builder(mContext) - .title("Package not found") - .content(callback.getPackageName() + " package was not found! Try to install it?") - .cancelable(false) - .positiveText("Yes") - .onPositive((dialog, which) -> callback.install()) - .negativeText("No") - .onNegative(((dialog, which) -> callback.cancel())) - .build()); - break; - case 1: - DialogUtils.showDialog(new MaterialDialog.Builder(mContext) - .title("OpenCV is not ready") - .content("Installation is in progress. Wait or exit?") - .cancelable(false) - .positiveText("Wait") - .onPositive((dialog, which) -> callback.wait_install()) - .negativeText("Exit") - .onNegative(((dialog, which) -> callback.cancel())) - .build()); - default: - finish(); - } - - } - - protected void finish() { + }).start(); + } else { + OpenCVLoader.initDebug(); + callback.onInitFinish(); } } - } diff --git a/common/release/output.json b/common/release/output.json index f27a16b10..0f307a92d 100644 --- a/common/release/output.json +++ b/common/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":454,"versionName":"4.1.0 Alpha4","enabled":true,"outputFile":"commonRelease-4.1.0 Alpha4.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.1.0 Alpha4.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":455,"versionName":"4.1.0 Alpha5","enabled":true,"outputFile":"commonRelease-4.1.0 Alpha5.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.1.0 Alpha5.apk","properties":{}}] \ No newline at end of file diff --git a/common/src/main/java/com/stardust/app/DialogUtils.java b/common/src/main/java/com/stardust/app/DialogUtils.java index 8dd778606..aba1bf97a 100644 --- a/common/src/main/java/com/stardust/app/DialogUtils.java +++ b/common/src/main/java/com/stardust/app/DialogUtils.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.ContextWrapper; import android.os.Build; +import android.os.Looper; import android.view.Window; import android.view.WindowManager; @@ -14,7 +15,7 @@ public class DialogUtils { - public static T showDialog(T dialog) { + public static T showDialog(final T dialog) { Context context = dialog.getContext(); if (!isActivityContext(context)) { @@ -28,7 +29,16 @@ public static T showDialog(T dialog) { if (window != null) window.setType(type); } - dialog.show(); + if (Looper.getMainLooper() == Looper.myLooper()) { + dialog.show(); + } else { + GlobalAppContext.post(new Runnable() { + @Override + public void run() { + dialog.show(); + } + }); + } return dialog; } diff --git a/project-versions.json b/project-versions.json index fc5c0f726..5f9d5e942 100644 --- a/project-versions.json +++ b/project-versions.json @@ -1,6 +1,6 @@ { - "appVersionCode": 454, - "appVersionName": "4.1.0 Alpha4", + "appVersionCode": 455, + "appVersionName": "4.1.0 Alpha5", "target": 28, "mini": 17, "compile": 28,