From 9b06086a5529f09ef6c2e54eb6d2cccb68e0c1d9 Mon Sep 17 00:00:00 2001 From: SuperMonster003 Date: Thu, 2 Oct 2025 17:29:58 +0800 Subject: [PATCH] =?UTF-8?q?6.7.0=20-=20Alpha6=20-=20=E4=BF=AE=E5=A4=8D=20A?= =?UTF-8?q?PK=20=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E5=8F=AF=E8=83=BD=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BA=94=E7=94=A8=E5=90=8D=E7=A7=B0=E5=8F=8A?= =?UTF-8?q?=20SDK=20=E4=BF=A1=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changelog/lang_zh-Hans.json | 1 + .../extension/MaterialDialogExtensions.kt | 31 +++++++++++++++---- .../ui/main/scripts/ApkInfoDialogManager.kt | 28 +++++++++++++++++ version.properties | 8 ++--- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index d1c2444a..e7cd190d 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -28,6 +28,7 @@ "部分设备无法正常初始化 MLKit Google OCR 的问题 (试修) _[`issue #8`](http://issues.autojs6.com/8#issuecomment-3117061768)_", "ErrorDialogActivity 可能无法正常启动的问题 _[`issue #414`](http://issues.autojs6.com/414)_ _[`issue #340`](http://issues.autojs6.com/340#issuecomment-2973485826)_", "崩溃报告页面复制详细信息功能失效的问题", + "APK 文件类型信息对话框可能无法获取应用名称及 SDK 信息的问题", "构建工具启用 isCleanup[Paddle/Rapid]Ocr 配置选项时无法正常完成 Rebuild Project 任务的问题" ], "improvement": [ diff --git a/app/src/main/java/org/autojs/autojs/extension/MaterialDialogExtensions.kt b/app/src/main/java/org/autojs/autojs/extension/MaterialDialogExtensions.kt index 8590ad33..349a115e 100644 --- a/app/src/main/java/org/autojs/autojs/extension/MaterialDialogExtensions.kt +++ b/app/src/main/java/org/autojs/autojs/extension/MaterialDialogExtensions.kt @@ -31,7 +31,7 @@ object MaterialDialogExtensions { @JvmStatic @JvmOverloads fun MaterialDialog.makeTextCopyable(textView: TextView?, textValue: String? = textView?.text?.toString()) { - if (textValue != null) { + if (!textValue.isNullOrBlank()) { val context = this.context textView?.setOnClickListener { ClipboardUtils.setClip(context, textValue) @@ -45,10 +45,17 @@ object MaterialDialogExtensions { } fun MaterialDialog.setCopyableTextIfAbsent(textView: TextView, textValue: String?, suffix: String? = null) { - if (textView.text == context.getString(R.string.ellipsis_six)) { - textView.text = textValue.takeUnless { it.isNullOrBlank() }?.let { it + (suffix ?: "") } ?: context.getString(R.string.text_unknown) + when { + textValue.isNullOrBlank() -> { + if (textView.isNullOrBlank() || textView.isEllipsisSix()) { + textView.setUnknown() + } + } + textView.isNullOrBlank() || textView.isEllipsisSix() || textView.isUnknown() -> { + textView.text = textValue + (suffix ?: "") + this.makeTextCopyable(textView, textValue) + } } - this.makeTextCopyable(textView, textValue) } fun MaterialDialog.setCopyableTextIfAbsent(textView: TextView, scope: CoroutineScope, f: () -> String?) { @@ -65,8 +72,15 @@ object MaterialDialogExtensions { } fun MaterialDialog.setCopyableText(textView: TextView, textValue: String?) { - textView.text = textValue.takeUnless { it.isNullOrBlank() } ?: context.getString(R.string.text_unknown) - this.makeTextCopyable(textView, textValue) + when { + textValue.isNullOrBlank() -> { + textView.setUnknown() + } + else -> { + textView.text = textValue + this.makeTextCopyable(textView, textValue) + } + } } @JvmStatic @@ -79,4 +93,9 @@ object MaterialDialogExtensions { it.widgetColor(ThemeColorHelper.getThemeColorStateList(context)) } + private fun TextView.setUnknown() = setText(R.string.text_unknown) + private fun TextView.isUnknown() = text == context.getString(R.string.text_unknown) + private fun TextView.isEllipsisSix() = text == context.getString(R.string.ellipsis_six) + private fun TextView.isNullOrBlank() = text.isNullOrBlank() + } diff --git a/app/src/main/java/org/autojs/autojs/ui/main/scripts/ApkInfoDialogManager.kt b/app/src/main/java/org/autojs/autojs/ui/main/scripts/ApkInfoDialogManager.kt index 6ef6a636..0c2ab72d 100644 --- a/app/src/main/java/org/autojs/autojs/ui/main/scripts/ApkInfoDialogManager.kt +++ b/app/src/main/java/org/autojs/autojs/ui/main/scripts/ApkInfoDialogManager.kt @@ -79,6 +79,7 @@ object ApkInfoDialogManager { scope.launch { val apkInfoDeferred = async(Dispatchers.IO) { getApkInfo(apkFile) } val packageInfoDeferred = async(Dispatchers.IO) { getPackageInfo(packageManager, apkFilePath) } + val sysBasicDeferred = async(Dispatchers.IO) { getBasicInfoFromPackageArchive(context, apkFilePath) } val firstPackageName: String? = select { apkInfoDeferred.onAwait { it?.packageName } @@ -115,6 +116,13 @@ object ApkInfoDialogManager { dialog.setCopyableTextIfAbsent(binding.fileSizeValue, this) { PFiles.getHumanReadableSize(apkFile.length()) } dialog.setCopyableTextIfAbsent(binding.signatureSchemeValue, this) { getApkSignatureInfo(apkFile) } + withContext(Dispatchers.Main) { + val sys = sysBasicDeferred.await() + dialog.setCopyableTextIfAbsent(binding.labelNameValue, sys?.label) + dialog.setCopyableTextIfAbsent(binding.minSdkValue, sys?.minSdk?.toString()) + dialog.setCopyableTextIfAbsent(binding.targetSdkValue, sys?.targetSdk?.toString()) + } + launch(Dispatchers.IO) { val apkInfo = apkInfoDeferred.await() @@ -255,6 +263,26 @@ object ApkInfoDialogManager { } }.getOrNull() + private fun getBasicInfoFromPackageArchive(context: Context, apkPath: String): SysBasicInfo? = runCatching { + val pm = context.packageManager + val pi = pm.getPackageArchiveInfo(apkPath, GET_META_DATA) ?: return@runCatching null + val ai = pi.applicationInfo?.apply { + sourceDir = apkPath + publicSourceDir = apkPath + } + SysBasicInfo( + label = ai?.loadLabel(pm)?.toString(), + minSdk = this.runCatching { ai?.minSdkVersion }.getOrNull()?.takeIf { it != 0 }, + targetSdk = ai?.targetSdkVersion?.takeIf { it != 0 }, + ) + }.getOrNull() + + private data class SysBasicInfo( + val label: String?, + val minSdk: Int?, + val targetSdk: Int?, + ) + private data class ApkInfo( val label: String?, val packageName: String?, diff --git a/version.properties b/version.properties index 4f87e7a2..229bd927 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Thu Oct 02 12:47:18 CST 2025 -BUILD_TIME=1759380438871 +#Thu Oct 02 17:27:13 CST 2025 +BUILD_TIME=1759397233140 COMPILE_SDK_VERSION=36 IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_NDK_VERSION=26.1.10909125 @@ -27,6 +27,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13 RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3 TARGET_SDK_VERSION=36 TARGET_SDK_VERSION_INRT=29 -VERSION_BUILD=3394 +VERSION_BUILD=3395 VERSION_NAME=6.7.0 Alpha6 -VSCODE_EXT_REQUIRED_VERSION=1.0.8 \ No newline at end of file +VSCODE_EXT_REQUIRED_VERSION=1.0.8