fix(android): 修复 App 内本地图片/视频选择无效的问题
- AndroidManifest.xml 补充 READ_MEDIA_IMAGES / READ_MEDIA_VIDEO 权限(Android 13+ 必需) - 将已废弃的 startActivityForResult 替换为 registerForActivityResult(Activity Result API),解决 Android 13+ 文件选择器回调丢失 - 同步更新 versionCode 24 / versionName 1.0.22
This commit is contained in:
parent
180fb9bfbd
commit
5723da8eb1
@ -1,5 +1,9 @@
|
||||
# App 更新说明
|
||||
|
||||
# 1.0.22
|
||||
- 修复 Android App 内从本地发送图片/视频无效的问题:补充 Android 13+ 所需的媒体读取权限(`READ_MEDIA_IMAGES` / `READ_MEDIA_VIDEO`)
|
||||
- 修复 Android App 文件选择器在 Android 13+ 上回调丢失的问题:将已废弃的 `startActivityForResult` 升级为 `registerForActivityResult`(Activity Result API)
|
||||
|
||||
# 1.0.21
|
||||
- 修复 Android App 内手机端展开“对话记录”时仍沿用旧宽度的问题,面板宽度与桌面端对话侧栏保持一致
|
||||
- 修复 Android App 内对话记录展开面板顶部残留系统栏空白的问题,内容从面板顶端开始显示
|
||||
|
||||
@ -16,8 +16,8 @@ android {
|
||||
applicationId = "com.cyjai.agent"
|
||||
minSdk = 24
|
||||
targetSdk = 35
|
||||
versionCode = 23
|
||||
versionName = "1.0.21"
|
||||
versionCode = 24
|
||||
versionName = "1.0.22"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
||||
@ -18,6 +18,8 @@ import android.webkit.WebSettings
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
@ -29,6 +31,14 @@ class MainActivity : AppCompatActivity() {
|
||||
private lateinit var webView: WebView
|
||||
private var filePathCallback: ValueCallback<Array<Uri>>? = null
|
||||
|
||||
private val fileChooserLauncher: ActivityResultLauncher<Intent> = registerForActivityResult(
|
||||
ActivityResultContracts.StartActivityForResult()
|
||||
) { result ->
|
||||
val results = WebChromeClient.FileChooserParams.parseResult(result.resultCode, result.data)
|
||||
filePathCallback?.onReceiveValue(results)
|
||||
filePathCallback = null
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -111,7 +121,7 @@ class MainActivity : AppCompatActivity() {
|
||||
addCategory(Intent.CATEGORY_OPENABLE)
|
||||
type = "*/*"
|
||||
}
|
||||
startActivityForResult(intent, FILE_CHOOSER_REQUEST_CODE)
|
||||
fileChooserLauncher.launch(intent)
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -136,16 +146,6 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode != FILE_CHOOSER_REQUEST_CODE) return
|
||||
|
||||
val results = WebChromeClient.FileChooserParams.parseResult(resultCode, data)
|
||||
filePathCallback?.onReceiveValue(results)
|
||||
filePathCallback = null
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
webView.saveState(outState)
|
||||
super.onSaveInstanceState(outState)
|
||||
@ -300,7 +300,6 @@ class MainActivity : AppCompatActivity() {
|
||||
companion object {
|
||||
private const val HOME_URL = "https://agent.cyjai.com"
|
||||
private const val WEB_ASSET_VERSION = "20260406_4"
|
||||
private const val FILE_CHOOSER_REQUEST_CODE = 9001
|
||||
}
|
||||
|
||||
private fun buildHomeUrl(): String {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user