6.6.2 - Alpha - 打包页面支持 Pinyin 库选项
This commit is contained in:
@@ -3,7 +3,8 @@
|
|||||||
"v6.6.2": {
|
"v6.6.2": {
|
||||||
"released_date": "2025/01/02",
|
"released_date": "2025/01/02",
|
||||||
"improvement": [
|
"improvement": [
|
||||||
"精简打包应用模板 APK 文件大小"
|
"精简打包应用模板 APK 文件大小",
|
||||||
|
"打包页面支持 Pinyin 库选项"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"v6.6.1": {
|
"v6.6.1": {
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ open class ApkBuilder(apkInputStream: InputStream?, private val outApkFile: File
|
|||||||
|
|
||||||
private val mAssetManager: AssetManager by lazy { globalContext.assets }
|
private val mAssetManager: AssetManager by lazy { globalContext.assets }
|
||||||
|
|
||||||
private var mLibsIncludes = Libs.DEFALUT_INCLUDES.toMutableList()
|
private var mLibsIncludes = Libs.defaultLibsToInclude.toMutableList()
|
||||||
private var mAssetsFileIncludes = Assets.File.DEFAULT_INCLUDES.toMutableList()
|
private var mAssetsFileIncludes = Libs.defaultAssetFilesToInclude.toMutableList()
|
||||||
private var mAssetsDirExcludes = Assets.Dir.DEFAULT_EXCLUDES.toMutableList()
|
private var mAssetsDirExcludes = Libs.defaultAssetDirsToExclude.toMutableList()
|
||||||
|
|
||||||
private val mManifestFile
|
private val mManifestFile
|
||||||
get() = File(workspacePath, "AndroidManifest.xml")
|
get() = File(workspacePath, "AndroidManifest.xml")
|
||||||
@@ -184,29 +184,12 @@ open class ApkBuilder(apkInputStream: InputStream?, private val outApkFile: File
|
|||||||
projectConfig.run {
|
projectConfig.run {
|
||||||
mKey = MD5Utils.md5(packageName + versionName + mainScriptFile)
|
mKey = MD5Utils.md5(packageName + versionName + mainScriptFile)
|
||||||
mInitVector = MD5Utils.md5(buildInfo.buildId + name).substring(0, 16)
|
mInitVector = MD5Utils.md5(buildInfo.buildId + name).substring(0, 16)
|
||||||
if (appConfig.libs.contains(Constants.OPENCV)) {
|
Libs.entries.forEach { entry ->
|
||||||
mLibsIncludes += Libs.OPENCV.toSet()
|
if (appConfig.libs.contains(entry.label)) {
|
||||||
mAssetsDirExcludes -= Assets.Dir.OPENCV.toSet()
|
mLibsIncludes += entry.libsToInclude.toSet()
|
||||||
}
|
mAssetsFileIncludes += entry.assetFilesToInclude.toSet()
|
||||||
if (appConfig.libs.contains(Constants.MLKIT_OCR)) {
|
mAssetsDirExcludes -= entry.assetDirsToExclude.toSet()
|
||||||
mLibsIncludes += Libs.MLKIT_GOOGLE_OCR.toSet()
|
}
|
||||||
mAssetsDirExcludes -= Assets.Dir.MLKIT_GOOGLE_OCR.toSet()
|
|
||||||
}
|
|
||||||
if (appConfig.libs.contains(Constants.PADDLE_OCR)) {
|
|
||||||
mLibsIncludes += Libs.PADDLE_LITE.toSet() + Libs.PADDLE_LITE_EXT.toSet()
|
|
||||||
mAssetsDirExcludes -= Assets.Dir.PADDLE_LITE.toSet()
|
|
||||||
}
|
|
||||||
if (appConfig.libs.contains(Constants.MLKIT_BARCODE)) {
|
|
||||||
mLibsIncludes += Libs.MLKIT_BARCODE.toSet()
|
|
||||||
mAssetsDirExcludes -= Assets.Dir.MLKIT_BARCODE.toSet()
|
|
||||||
}
|
|
||||||
if (appConfig.libs.contains(Constants.RAPID_OCR)) {
|
|
||||||
mLibsIncludes += Libs.RAPID_OCR.toSet()
|
|
||||||
mAssetsDirExcludes -= Assets.Dir.RAPID_OCR.toSet()
|
|
||||||
}
|
|
||||||
if (appConfig.libs.contains(Constants.OPENCC)) {
|
|
||||||
mLibsIncludes += Libs.OPENCC.toSet()
|
|
||||||
mAssetsDirExcludes -= Assets.Dir.OPENCC.toSet()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,119 +461,126 @@ open class ApkBuilder(apkInputStream: InputStream?, private val outApkFile: File
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
enum class Libs(
|
||||||
object Libs {
|
@JvmField val label: String,
|
||||||
|
@JvmField val aliases: List<String> = emptyList(),
|
||||||
|
@JvmField val enumerable: Boolean = true,
|
||||||
|
internal val libsToInclude: List<String> = emptyList(),
|
||||||
|
internal val assetFilesToInclude: List<String> = emptyList(),
|
||||||
|
internal val assetDirsToExclude: List<String> = emptyList(),
|
||||||
|
) {
|
||||||
|
|
||||||
private val BASIC = listOf(
|
TERMINAL_EMULATOR(
|
||||||
"libjackpal-androidterm5.so", /* Terminal Emulator. */
|
label = "Terminal Emulator",
|
||||||
"libjackpal-termexec2.so", /* Terminal Emulator. */
|
enumerable = false,
|
||||||
)
|
libsToInclude = listOf(
|
||||||
|
"libjackpal-androidterm5.so",
|
||||||
|
"libjackpal-termexec2.so",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
private val MISCELLANEOUS = emptyList<String>()
|
OPENCV(
|
||||||
|
label = "OpenCV",
|
||||||
@JvmField
|
aliases = listOf("cv"),
|
||||||
val OPENCV = listOf(
|
libsToInclude = listOf(
|
||||||
"libc++_shared.so",
|
"libc++_shared.so",
|
||||||
"libopencv_java4.so",
|
"libopencv_java4.so",
|
||||||
)
|
),
|
||||||
|
),
|
||||||
|
|
||||||
@JvmField
|
MLKIT_OCR(
|
||||||
val MLKIT_GOOGLE_OCR = listOf(
|
label = "MLKit OCR",
|
||||||
|
aliases = listOf("mlkit", "mlkitocr", "mlkit-ocr", "mlkit_ocr"),
|
||||||
|
libsToInclude = listOf(
|
||||||
"libmlkit_google_ocr_pipeline.so",
|
"libmlkit_google_ocr_pipeline.so",
|
||||||
)
|
),
|
||||||
|
assetDirsToExclude = listOf(
|
||||||
|
"mlkit-google-ocr-models",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
@JvmField
|
PADDLE_OCR(
|
||||||
val PADDLE_LITE = listOf(
|
label = "Paddle OCR",
|
||||||
|
aliases = listOf("paddle", "paddleocr", "paddle-ocr", "paddle_ocr"),
|
||||||
|
libsToInclude = listOf(
|
||||||
"libc++_shared.so",
|
"libc++_shared.so",
|
||||||
"libpaddle_light_api_shared.so",
|
"libpaddle_light_api_shared.so",
|
||||||
"libNative.so",
|
"libNative.so",
|
||||||
)
|
|
||||||
|
|
||||||
val PADDLE_LITE_EXT = listOf(
|
|
||||||
"libhiai.so",
|
"libhiai.so",
|
||||||
"libhiai_ir.so",
|
"libhiai_ir.so",
|
||||||
"libhiai_ir_build.so",
|
"libhiai_ir_build.so",
|
||||||
|
),
|
||||||
|
assetDirsToExclude = listOf(
|
||||||
|
"models",
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
|
||||||
@JvmField
|
RAPID_OCR(
|
||||||
val MLKIT_BARCODE = emptyList<String>()
|
label = "Rapid OCR",
|
||||||
|
aliases = listOf("rapid", "rapidocr", "rapid-ocr", "rapid_ocr"),
|
||||||
@JvmField
|
libsToInclude = listOf(
|
||||||
val RAPID_OCR = listOf(
|
|
||||||
"libRapidOcr.so",
|
"libRapidOcr.so",
|
||||||
)
|
),
|
||||||
|
assetDirsToExclude = listOf(
|
||||||
|
"labels",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
@JvmField
|
OPENCC(
|
||||||
val OPENCC = listOf(
|
label = "OpenCC",
|
||||||
|
aliases = listOf("cc"),
|
||||||
|
libsToInclude = listOf(
|
||||||
"libChineseConverter.so",
|
"libChineseConverter.so",
|
||||||
)
|
),
|
||||||
|
assetDirsToExclude = listOf(
|
||||||
|
"openccdata",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
val DEFALUT_INCLUDES: List<String> = (BASIC + MISCELLANEOUS).distinct()
|
PINYIN(
|
||||||
|
label = "Pinyin",
|
||||||
|
aliases = listOf("pin"),
|
||||||
|
assetFilesToInclude = listOf(
|
||||||
|
"dict-chinese-words.db.gzip",
|
||||||
|
"dict-chinese-phrases.db.gzip",
|
||||||
|
"dict-chinese-chars.db.gzip",
|
||||||
|
"prob_emit.txt",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
@JvmStatic
|
MLKIT_BARCODE(
|
||||||
fun ensure(name: String, libNameList: List<String>) {
|
label = "MLKit Barcode",
|
||||||
|
aliases = listOf("barcode", "mlkit-barcode", "mlkit_barcode"),
|
||||||
|
assetDirsToExclude = listOf(
|
||||||
|
"mlkit_barcode_models",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
fun ensureLibFiles(moduleName: String = label) {
|
||||||
if (!BuildConfig.isInrt) return
|
if (!BuildConfig.isInrt) return
|
||||||
val nativeLibraryDir = File(globalContext.applicationInfo.nativeLibraryDir)
|
val nativeLibraryDir = File(globalContext.applicationInfo.nativeLibraryDir)
|
||||||
val primaryNativeLibraries = nativeLibraryDir.list()?.toList() ?: emptyList()
|
val primaryNativeLibraries = nativeLibraryDir.list()?.toList() ?: emptyList()
|
||||||
if (!primaryNativeLibraries.containsAll(libNameList)) {
|
if (!primaryNativeLibraries.containsAll(libsToInclude)) {
|
||||||
throw Exception(globalContext.getString(R.string.error_module_does_not_work_due_to_the_lack_of_necessary_library_files, name))
|
throw Exception(globalContext.getString(R.string.error_module_does_not_work_due_to_the_lack_of_necessary_library_files, moduleName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
companion object {
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
val defaultLibsToInclude = listOf(
|
||||||
object Assets {
|
TERMINAL_EMULATOR,
|
||||||
|
).flatMap { it.libsToInclude }
|
||||||
|
|
||||||
object File {
|
val defaultAssetFilesToInclude = listOf(
|
||||||
|
"init.js", "roboto_medium.ttf",
|
||||||
private val BASIC = listOf(
|
|
||||||
"init.js", "roboto_medium.ttf"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private val MISCELLANEOUS = emptyList<String>()
|
val defaultAssetDirsToExclude = listOf(
|
||||||
|
"doc", "docs", "editor", "indices", "js-beautify", "sample", "stored-locales",
|
||||||
val DEFAULT_INCLUDES = (BASIC + MISCELLANEOUS).distinct()
|
) + Libs.entries.flatMap { it.assetDirsToExclude }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object Dir {
|
|
||||||
|
|
||||||
private val BASIC = listOf("doc", "docs", "editor", "indices", "js-beautify", "sample")
|
|
||||||
|
|
||||||
private val MISCELLANEOUS = listOf("stored-locales")
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val OPENCV = emptyList<String>()
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val MLKIT_GOOGLE_OCR = listOf("mlkit-google-ocr-models")
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val MLKIT_BARCODE = listOf("mlkit_barcode_models")
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val PADDLE_LITE = listOf("models")
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val RAPID_OCR = listOf("labels")
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val OPENCC = listOf("openccdata")
|
|
||||||
|
|
||||||
val DEFAULT_EXCLUDES = (BASIC + MLKIT_GOOGLE_OCR + MLKIT_BARCODE + PADDLE_LITE + RAPID_OCR + OPENCC + MISCELLANEOUS).distinct()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
object Constants {
|
|
||||||
const val OPENCV = "OpenCV"
|
|
||||||
const val MLKIT_OCR = "MLKit OCR"
|
|
||||||
const val PADDLE_OCR = "Paddle OCR"
|
|
||||||
const val RAPID_OCR = "Rapid OCR"
|
|
||||||
const val OPENCC = "OpenCC"
|
|
||||||
const val MLKIT_BARCODE = "MLKit Barcode"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ class OcrMLKit(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRun
|
|||||||
// ! Reserved param `options`.
|
// ! Reserved param `options`.
|
||||||
// ! zh-CN: 预留参数 `options`.
|
// ! zh-CN: 预留参数 `options`.
|
||||||
fun recognizeTextInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, @Suppress("UNUSED_PARAMETER") options: NativeObject): List<String> {
|
fun recognizeTextInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, @Suppress("UNUSED_PARAMETER") options: NativeObject): List<String> {
|
||||||
ApkBuilder.Libs.ensure(OcrMode.MLKIT.value, ApkBuilder.Libs.MLKIT_GOOGLE_OCR)
|
ApkBuilder.Libs.MLKIT_OCR.ensureLibFiles(OcrMode.MLKIT.value)
|
||||||
return scriptRuntime.ocrMLKit.recognizeText(image)
|
return scriptRuntime.ocrMLKit.recognizeText(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class OcrMLKit(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRun
|
|||||||
// ! Reserved param `options`.
|
// ! Reserved param `options`.
|
||||||
// ! zh-CN: 预留参数 `options`.
|
// ! zh-CN: 预留参数 `options`.
|
||||||
fun detectInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, @Suppress("UNUSED_PARAMETER") options: NativeObject): List<OcrResult> {
|
fun detectInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, @Suppress("UNUSED_PARAMETER") options: NativeObject): List<OcrResult> {
|
||||||
ApkBuilder.Libs.ensure(OcrMode.MLKIT.value, ApkBuilder.Libs.MLKIT_GOOGLE_OCR)
|
ApkBuilder.Libs.MLKIT_OCR.ensureLibFiles(OcrMode.MLKIT.value)
|
||||||
return scriptRuntime.ocrMLKit.detect(image)
|
return scriptRuntime.ocrMLKit.detect(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ class OcrPaddle(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRu
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun recognizeTextInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, options: NativeObject): List<String> {
|
fun recognizeTextInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, options: NativeObject): List<String> {
|
||||||
ApkBuilder.Libs.ensure(OcrMode.PADDLE.value, ApkBuilder.Libs.PADDLE_LITE)
|
ApkBuilder.Libs.PADDLE_OCR.ensureLibFiles(OcrMode.PADDLE.value)
|
||||||
val (cpuThreadNum, useSlim) = getOptions(options)
|
val (cpuThreadNum, useSlim) = getOptions(options)
|
||||||
return scriptRuntime.ocrPaddle.recognizeText(image, cpuThreadNum, useSlim)
|
return scriptRuntime.ocrPaddle.recognizeText(image, cpuThreadNum, useSlim)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun detectInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, options: NativeObject): List<OcrResult> {
|
fun detectInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, options: NativeObject): List<OcrResult> {
|
||||||
ApkBuilder.Libs.ensure(OcrMode.PADDLE.value, ApkBuilder.Libs.PADDLE_LITE)
|
ApkBuilder.Libs.PADDLE_OCR.ensureLibFiles(OcrMode.PADDLE.value)
|
||||||
val (cpuThreadNum, useSlim) = getOptions(options)
|
val (cpuThreadNum, useSlim) = getOptions(options)
|
||||||
return scriptRuntime.ocrPaddle.detect(image, cpuThreadNum, useSlim).map { result ->
|
return scriptRuntime.ocrPaddle.detect(image, cpuThreadNum, useSlim).map { result ->
|
||||||
OcrResult(result.label, result.confidence, result.bounds)
|
OcrResult(result.label, result.confidence, result.bounds)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class OcrRapid(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRun
|
|||||||
// ! Reserved param `options`.
|
// ! Reserved param `options`.
|
||||||
// ! zh-CN: 预留参数 `options`.
|
// ! zh-CN: 预留参数 `options`.
|
||||||
fun recognizeTextInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, @Suppress("UNUSED_PARAMETER") options: NativeObject): List<String> {
|
fun recognizeTextInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, @Suppress("UNUSED_PARAMETER") options: NativeObject): List<String> {
|
||||||
ApkBuilder.Libs.ensure(OcrMode.RAPID.value, ApkBuilder.Libs.RAPID_OCR)
|
ApkBuilder.Libs.RAPID_OCR.ensureLibFiles(OcrMode.RAPID.value)
|
||||||
return scriptRuntime.ocrRapid.recognizeText(image)
|
return scriptRuntime.ocrRapid.recognizeText(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class OcrRapid(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRun
|
|||||||
// ! Reserved param `options`.
|
// ! Reserved param `options`.
|
||||||
// ! zh-CN: 预留参数 `options`.
|
// ! zh-CN: 预留参数 `options`.
|
||||||
fun detectInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, @Suppress("UNUSED_PARAMETER") options: NativeObject): List<OcrResult> {
|
fun detectInternal(scriptRuntime: ScriptRuntime, image: ImageWrapper, @Suppress("UNUSED_PARAMETER") options: NativeObject): List<OcrResult> {
|
||||||
ApkBuilder.Libs.ensure(OcrMode.RAPID.value, ApkBuilder.Libs.RAPID_OCR)
|
ApkBuilder.Libs.RAPID_OCR.ensureLibFiles(OcrMode.RAPID.value)
|
||||||
return scriptRuntime.ocrRapid.detect(image)
|
return scriptRuntime.ocrRapid.detect(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import android.util.Log;
|
|||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -22,7 +22,6 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.google.android.flexbox.FlexboxLayout;
|
import com.google.android.flexbox.FlexboxLayout;
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
@@ -30,6 +29,7 @@ import io.reactivex.Observable;
|
|||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import org.autojs.autojs.apkbuilder.ApkBuilder;
|
import org.autojs.autojs.apkbuilder.ApkBuilder;
|
||||||
|
import org.autojs.autojs.apkbuilder.keystore.KeyStore;
|
||||||
import org.autojs.autojs.core.pref.Language;
|
import org.autojs.autojs.core.pref.Language;
|
||||||
import org.autojs.autojs.model.explorer.Explorers;
|
import org.autojs.autojs.model.explorer.Explorers;
|
||||||
import org.autojs.autojs.model.script.ScriptFile;
|
import org.autojs.autojs.model.script.ScriptFile;
|
||||||
@@ -41,10 +41,9 @@ import org.autojs.autojs.runtime.api.augment.pinyin.Pinyin;
|
|||||||
import org.autojs.autojs.ui.BaseActivity;
|
import org.autojs.autojs.ui.BaseActivity;
|
||||||
import org.autojs.autojs.ui.common.NotAskAgainDialog;
|
import org.autojs.autojs.ui.common.NotAskAgainDialog;
|
||||||
import org.autojs.autojs.ui.filechooser.FileChooserDialogBuilder;
|
import org.autojs.autojs.ui.filechooser.FileChooserDialogBuilder;
|
||||||
import org.autojs.autojs.apkbuilder.keystore.KeyStore;
|
|
||||||
import org.autojs.autojs.ui.viewmodel.KeyStoreViewModel;
|
|
||||||
import org.autojs.autojs.ui.keystore.ManageKeyStoreActivity;
|
import org.autojs.autojs.ui.keystore.ManageKeyStoreActivity;
|
||||||
import org.autojs.autojs.ui.shortcut.AppsIconSelectActivity;
|
import org.autojs.autojs.ui.shortcut.AppsIconSelectActivity;
|
||||||
|
import org.autojs.autojs.ui.viewmodel.KeyStoreViewModel;
|
||||||
import org.autojs.autojs.ui.widget.RoundCheckboxWithText;
|
import org.autojs.autojs.ui.widget.RoundCheckboxWithText;
|
||||||
import org.autojs.autojs.util.AndroidUtils;
|
import org.autojs.autojs.util.AndroidUtils;
|
||||||
import org.autojs.autojs.util.AndroidUtils.Abi;
|
import org.autojs.autojs.util.AndroidUtils.Abi;
|
||||||
@@ -65,7 +64,6 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -102,25 +100,9 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
|||||||
put(Abi.ARMEABI, /* armeabi */ List.of("armeabi", "arme", "armv5te", "arm5te", "armv5", "v5", "arm5", "5"));
|
put(Abi.ARMEABI, /* armeabi */ List.of("armeabi", "arme", "armv5te", "arm5te", "armv5", "v5", "arm5", "5"));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
private static final ArrayList<String> SUPPORTED_LIBS = new ArrayList<>() {{
|
private static final ArrayList<String> SUPPORTED_LIBS = new ArrayList<>();
|
||||||
add(ApkBuilder.Constants.OPENCV);
|
|
||||||
add(ApkBuilder.Constants.MLKIT_OCR);
|
|
||||||
add(ApkBuilder.Constants.PADDLE_OCR);
|
|
||||||
add(ApkBuilder.Constants.RAPID_OCR);
|
|
||||||
add(ApkBuilder.Constants.OPENCC);
|
|
||||||
// add(ApkBuilder.Constants.PINYIN);
|
|
||||||
add(ApkBuilder.Constants.MLKIT_BARCODE);
|
|
||||||
}};
|
|
||||||
|
|
||||||
private static final Map<String, List<String>> LIB_ALIASES = new HashMap<>() {{
|
private static final Map<String, List<String>> LIB_ALIASES = new HashMap<>();
|
||||||
put(ApkBuilder.Constants.OPENCV, List.of("cv"));
|
|
||||||
put(ApkBuilder.Constants.MLKIT_OCR, List.of("mlkit", "mlkitocr", "mlkit-ocr", "mlkit_ocr"));
|
|
||||||
put(ApkBuilder.Constants.PADDLE_OCR, List.of("paddle", "paddleocr", "paddle-ocr", "paddle_ocr"));
|
|
||||||
put(ApkBuilder.Constants.RAPID_OCR, List.of("rapid", "rapidocr", "rapid-ocr", "rapid_ocr"));
|
|
||||||
put(ApkBuilder.Constants.OPENCC, List.of("cc"));
|
|
||||||
// put(ApkBuilder.Constants.PINYIN, List.of("pin"));
|
|
||||||
put(ApkBuilder.Constants.MLKIT_BARCODE, List.of("barcode", "mlkit-barcode", "mlkit_barcode"));
|
|
||||||
}};
|
|
||||||
|
|
||||||
private static final ArrayList<String> SIGNATURE_SCHEMES = new ArrayList<>() {{
|
private static final ArrayList<String> SIGNATURE_SCHEMES = new ArrayList<>() {{
|
||||||
add("V1 + V2");
|
add("V1 + V2");
|
||||||
@@ -209,6 +191,15 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
|||||||
|
|
||||||
private KeyStoreViewModel mKeyStoreViewModel;
|
private KeyStoreViewModel mKeyStoreViewModel;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (ApkBuilder.Libs entry : ApkBuilder.Libs.getEntries()) {
|
||||||
|
if (entry.enumerable) {
|
||||||
|
SUPPORTED_LIBS.add(entry.label);
|
||||||
|
LIB_ALIASES.put(entry.label, entry.aliases);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ android {
|
|||||||
// 主 Java/Kotlin 目录
|
// 主 Java/Kotlin 目录
|
||||||
java.srcDirs = ['src/main/java']
|
java.srcDirs = ['src/main/java']
|
||||||
// 将资源文件夹指定为 assets 目录
|
// 将资源文件夹指定为 assets 目录
|
||||||
assets.srcDirs = ['src/main/resources']
|
assets.srcDirs = ['src/main/assets']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class JiebaSegmenter(context: Context) {
|
|||||||
|
|
||||||
val dictionary by lazy { WordDictionary.getInstance(context) }
|
val dictionary by lazy { WordDictionary.getInstance(context) }
|
||||||
|
|
||||||
private val finalSeg by lazy { FinalSeg.instance }
|
private val finalSeg by lazy { FinalSeg.getInstance(context) }
|
||||||
|
|
||||||
enum class SegMode { INDEX, SEARCH }
|
enum class SegMode { INDEX, SEARCH }
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.huaban.analysis.jieba.viterbi
|
package com.huaban.analysis.jieba.viterbi
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import com.huaban.analysis.jieba.CharacterUtil
|
import com.huaban.analysis.jieba.CharacterUtil
|
||||||
import com.huaban.analysis.jieba.Log
|
import com.huaban.analysis.jieba.Log
|
||||||
import com.huaban.analysis.jieba.Node
|
import com.huaban.analysis.jieba.Node
|
||||||
@@ -11,7 +12,7 @@ import java.nio.charset.Charset
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class FinalSeg private constructor() {
|
class FinalSeg private constructor() {
|
||||||
private fun loadModel() {
|
private fun loadModel(context: Context) {
|
||||||
val s = System.currentTimeMillis()
|
val s = System.currentTimeMillis()
|
||||||
val prevStatus = HashMap<Char, CharArray>().also { prevStatus = it }
|
val prevStatus = HashMap<Char, CharArray>().also { prevStatus = it }
|
||||||
prevStatus['B'] = charArrayOf('E', 'S')
|
prevStatus['B'] = charArrayOf('E', 'S')
|
||||||
@@ -43,7 +44,8 @@ class FinalSeg private constructor() {
|
|||||||
transS['S'] = -0.6658631448798212
|
transS['S'] = -0.6658631448798212
|
||||||
trans['S'] = transS
|
trans['S'] = transS
|
||||||
|
|
||||||
val `is` = javaClass.getResourceAsStream(PROB_EMIT)!!
|
// val `is` = javaClass.getResourceAsStream(PROB_EMIT)!!
|
||||||
|
val `is` = context.assets.open(PROB_EMIT)
|
||||||
try {
|
try {
|
||||||
val br = BufferedReader(InputStreamReader(`is`, Charset.forName("UTF-8")))
|
val br = BufferedReader(InputStreamReader(`is`, Charset.forName("UTF-8")))
|
||||||
val emit = HashMap<Char, Map<Char, Double>>().also { emit = it }
|
val emit = HashMap<Char, Map<Char, Double>>().also { emit = it }
|
||||||
@@ -181,7 +183,7 @@ class FinalSeg private constructor() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var singleInstance: FinalSeg? = null
|
private var singleInstance: FinalSeg? = null
|
||||||
private const val PROB_EMIT = "/prob_emit.txt"
|
private const val PROB_EMIT = "prob_emit.txt"
|
||||||
private val states = charArrayOf('B', 'M', 'E', 'S')
|
private val states = charArrayOf('B', 'M', 'E', 'S')
|
||||||
private var emit: MutableMap<Char, Map<Char, Double>>? = null
|
private var emit: MutableMap<Char, Map<Char, Double>>? = null
|
||||||
private var start: MutableMap<Char, Double>? = null
|
private var start: MutableMap<Char, Double>? = null
|
||||||
@@ -189,13 +191,12 @@ class FinalSeg private constructor() {
|
|||||||
private var prevStatus: MutableMap<Char, CharArray>? = null
|
private var prevStatus: MutableMap<Char, CharArray>? = null
|
||||||
private const val MIN_FLOAT = -3.14e100
|
private const val MIN_FLOAT = -3.14e100
|
||||||
|
|
||||||
@get:Synchronized
|
@Synchronized
|
||||||
val instance: FinalSeg
|
fun getInstance(context: Context): FinalSeg {
|
||||||
get() {
|
if (singleInstance == null) {
|
||||||
if (singleInstance == null) {
|
singleInstance = FinalSeg().apply { loadModel(context) }
|
||||||
singleInstance = FinalSeg().apply { loadModel() }
|
|
||||||
}
|
|
||||||
return singleInstance!!
|
|
||||||
}
|
}
|
||||||
|
return singleInstance!!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#Thu Jan 02 18:05:40 CST 2025
|
#Thu Jan 02 21:17:00 CST 2025
|
||||||
BUILD_TIME=1735812340458
|
BUILD_TIME=1735823820696
|
||||||
COMPILE_SDK_VERSION=34
|
COMPILE_SDK_VERSION=34
|
||||||
JAVA_VERSION=23
|
JAVA_VERSION=23
|
||||||
JAVA_VERSION_MIN_RADICAL=0
|
JAVA_VERSION_MIN_RADICAL=0
|
||||||
@@ -17,6 +17,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
|
|||||||
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
||||||
TARGET_SDK_VERSION=34
|
TARGET_SDK_VERSION=34
|
||||||
TARGET_SDK_VERSION_INRT=29
|
TARGET_SDK_VERSION_INRT=29
|
||||||
VERSION_BUILD=2944
|
VERSION_BUILD=2945
|
||||||
VERSION_NAME=6.6.2 Alpha
|
VERSION_NAME=6.6.2 Alpha
|
||||||
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
||||||
|
|||||||
Reference in New Issue
Block a user