Explorar el Código

2026-05-08 更新

1. 代码优化, 更新部分依赖, 适配AndroidSDK 37
zhaiy hace 3 días
padre
commit
a9f9d857c2

+ 2 - 2
app/build.gradle.kts

@@ -5,7 +5,7 @@ plugins {
 
 android {
     namespace = "com.pan_american.android"
-    compileSdk = 36
+    compileSdk = 37
 
     buildFeatures {
         viewBinding = true
@@ -16,7 +16,7 @@ android {
     defaultConfig {
         applicationId = "com.pan_american.android"
         minSdk = 26
-        targetSdk = 36
+        targetSdk = android.compileSdk
         versionCode = 19
         versionName = "1.0.18"
 

+ 23 - 27
app/src/main/java/com/pan_american/android/data/network/SseService.kt

@@ -2,17 +2,16 @@ package com.pan_american.android.data.network
 
 import com.google.gson.Gson
 import com.pan_american.android.OASystem
+import okhttp3.Call
 import okhttp3.MediaType.Companion.toMediaType
-import okhttp3.RequestBody
 import okhttp3.Request
+import okhttp3.RequestBody
 import okhttp3.RequestBody.Companion.toRequestBody
-import okhttp3.Call
-import okhttp3.Callback
 import okhttp3.Response
-import java.io.IOException
 import okhttp3.sse.EventSource
 import okhttp3.sse.EventSourceListener
 import okhttp3.sse.EventSources
+import java.io.IOException
 import kotlin.concurrent.thread
 
 /**
@@ -61,25 +60,25 @@ object SseService {
     /**
      * GET 的 SSE 连接(参数需要调用方自行拼到 path/query 中)。
      */
-    fun connectGet(
-        pathWithQuery: String,
-        listener: EventSourceListener,
-        addAuthHeader: Boolean = true
-    ): EventSource {
-        val url = ServiceCreator.baseUrl().trimEnd('/') + pathWithQuery
-        val request = Request.Builder()
-            .url(url)
-            .get()
-            .header("Accept", "text/event-stream")
-            .apply {
-                if (addAuthHeader && OASystem.token.isNotBlank()) {
-                    header("Authorization", OASystem.token)
-                }
-            }
-            .build()
-
-        return factory.newEventSource(request, listener)
-    }
+//    fun connectGet(
+//        pathWithQuery: String,
+//        listener: EventSourceListener,
+//        addAuthHeader: Boolean = true
+//    ): EventSource {
+//        val url = ServiceCreator.baseUrl().trimEnd('/') + pathWithQuery
+//        val request = Request.Builder()
+//            .url(url)
+//            .get()
+//            .header("Accept", "text/event-stream")
+//            .apply {
+//                if (addAuthHeader && OASystem.token.isNotBlank()) {
+//                    header("Authorization", OASystem.token)
+//                }
+//            }
+//            .build()
+//
+//        return factory.newEventSource(request, listener)
+//    }
 
     /**
      * POST + JSON 的 NDJSON 流式接口(Content-Type: application/x-ndjson)。
@@ -120,10 +119,7 @@ object SseService {
             var resp: Response? = null
             try {
                 resp = call.execute()
-                val bodyStream = resp.body ?: run {
-                    onFailure(IllegalStateException("Empty body"), resp)
-                    return@thread
-                }
+                val bodyStream = resp.body
                 val source = bodyStream.source()
                 while (!call.isCanceled()) {
                     val line = source.readUtf8Line() ?: break

+ 2 - 3
app/src/main/java/com/pan_american/android/util/ScrollEditText.kt

@@ -11,7 +11,6 @@ import android.view.inputmethod.InputMethodManager
 import android.widget.EditText
 import android.widget.LinearLayout
 import android.widget.TextView
-import com.pan_american.android.OASystem
 import com.pan_american.android.R
 
 class ScrollEditText(context: Context, attrs: AttributeSet?) : LinearLayout(context, attrs) {
@@ -80,9 +79,9 @@ class ScrollEditText(context: Context, attrs: AttributeSet?) : LinearLayout(cont
                         editTextField.requestFocus()
 
                         val inputMethodManager =
-                            OASystem.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+                            editTextField.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
                         inputMethodManager.showSoftInput(
-                            editTextField, InputMethodManager.SHOW_IMPLICIT
+                            editTextField, 0
                         )
                     } else {
                         parent.parent.requestDisallowInterceptTouchEvent(false)

+ 0 - 1
gradle.properties

@@ -22,7 +22,6 @@ kotlin.code.style=official
 # thereby reducing the size of the R class for that library
 android.nonTransitiveRClass=true
 
-android.enableJetifier=true
 #org.gradle.unsafe.configuration-cache=true
 systemProp.https.protocols=TLSv1.2,TLSv1.1,TLSv1
 systemProp.http.protocols=TLSv1.2,TLSv1.1,TLSv1

+ 14 - 14
gradle/libs.versions.toml

@@ -1,27 +1,27 @@
 [versions]
-agp = "9.1.0"
-kotlin = "2.3.20"
-coreKtx = "1.16.0"
+agp = "9.2.1"
+kotlin = "2.3.21"
+coreKtx = "1.18.0"
 junit = "4.13.2"
-junitVersion = "1.2.1"
-espressoCore = "3.6.1"
+junitVersion = "1.3.0"
+espressoCore = "3.7.0"
 appcompat = "1.7.1"
-composeBom = "2025.12.01"
-material = "1.12.0"
-activity = "1.12.2"
-lifecycle = "2.8.7"
-constraintlayout = "2.1.4"
-recyclerview = "1.3.1"
-viewpager2 = "1.0.0"
+composeBom = "2026.05.00"
+material = "1.13.0"
+activity = "1.13.0"
+lifecycle = "2.10.0"
+constraintlayout = "2.2.1"
+recyclerview = "1.4.0"
+viewpager2 = "1.1.0"
 
 retrofit2 = "3.0.0"
 smartRefreshLayout = "2.1.1"
 eventbus = "3.3.1"
-signalr = "10.0.5"
+signalr = "10.0.7"
 smartTable = "2.2.0"
 mpAndroidChart = "v3.1.0"
 picasso = "2.71828"
-matisse = "2.3.0"
+matisse = "2.3.2"
 markwon = "4.6.2"
 okhttp-sse = "5.3.2"
 richeditor = "2.0.0"

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
 #Tue Jun 10 16:01:51 CST 2025
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists