Przeglądaj źródła

fix(lint): 清掉 9 个既存 lint 错误,让 verify 门禁真正可用

verify.yml 首次在 main 跑通编译后卡在 lintAppDebug——9 个错误全部是 CI
不跑 lint 期间累积的既存债,与 R1 改造无关。按基线纪律选择修复而非扩基线:

- LocalContextGetResourceValueCall ×3(LabConfigScreen、TtsCacheScreen ×2):
  组合期取字符串改用 stringResource;LabConfigScreen 那处在 LaunchedEffect
  里,把取值提到组合期再捕获。
- RememberReturnType ×1(MainNavGraph):这里刻意用 remember 跑副作用——
  ReadView 首次组合就画一帧,LaunchedEffect 赶不上。加 @Suppress 并写明原因。
- MissingTranslation ×6:色温与护眼定时的 6 个字符串补 zh-rCN/rHK/rTW 翻译。

验证:lintAppDebug 0 error(30 个历史错误仍由基线冻结)+ 413 单测全绿。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5151561 3 miesięcy temu
rodzic
commit
1403ae6de0

+ 2 - 2
app/src/main/java/io/legado/app/ui/book/readaloud/cache/TtsCacheScreen.kt

@@ -109,7 +109,7 @@ fun TtsCacheScreen(
                 item {
                     val sizeText = TtsCacheViewModel.formatSize(state.totalSizeBytes)
                     val countText =
-                        context.getString(R.string.tts_cache_file_count, state.files.size)
+                        stringResource(R.string.tts_cache_file_count, state.files.size)
                     TinyClickableSettingItem(
                         title = stringResource(R.string.tts_cache_total),
                         description = "$sizeText · $countText",
@@ -129,7 +129,7 @@ fun TtsCacheScreen(
                     val sizeText = TtsCacheViewModel.formatSize(file.sizeBytes)
                     val dateText = dateFormat.format(Date(file.lastModified))
                     val displayText = file.text.ifEmpty {
-                        context.getString(R.string.tts_cache_unknown_text)
+                        stringResource(R.string.tts_cache_unknown_text)
                     }
                     TinyClickableSettingItem(
                         title = displayText,

+ 2 - 6
app/src/main/java/io/legado/app/ui/config/labConfig/LabConfigScreen.kt

@@ -36,6 +36,7 @@ fun LabConfigRouteScreen(
     viewModel: LabConfigViewModel = koinViewModel(),
 ) {
     val context = LocalContext.current
+    val shareTitle = stringResource(R.string.lab_page_estimate_diagnostics_share_title)
     LaunchedEffect(viewModel) {
         viewModel.effects.collectLatest { effect ->
             when (effect) {
@@ -44,12 +45,7 @@ fun LabConfigRouteScreen(
                         putExtra(Intent.EXTRA_TEXT, effect.text)
                         type = "text/plain"
                     }
-                    context.startActivity(
-                        Intent.createChooser(
-                            sendIntent,
-                            context.getString(R.string.lab_page_estimate_diagnostics_share_title),
-                        )
-                    )
+                    context.startActivity(Intent.createChooser(sendIntent, shareTitle))
                 }
             }
         }

+ 3 - 1
app/src/main/java/io/legado/app/ui/main/MainNavGraph.kt

@@ -411,7 +411,9 @@ fun MainActivity.mainEntryProvider(
         val controller = remember(readBookViewModel) {
             ReadBookController(this@mainEntryProvider, readBookViewModel)
         }
-        // ReadView 在首次组合时就会画一帧, 必须在它之前告诉 ViewModel 本路由要打开哪本书
+        // ReadView 在首次组合时就会画一帧, 必须在它之前告诉 ViewModel 本路由要打开哪本书。
+        // 刻意用 remember 而非 LaunchedEffect:后者在组合之后才跑,赶不上首帧。
+        @Suppress("RememberReturnType")
         remember(readBookViewModel, route) {
             readBookViewModel.prepareCachedChapterFallback(route.bookUrl, route.chapterChanged)
         }

+ 6 - 0
app/src/main/res/values-zh-rCN/strings.xml

@@ -2240,6 +2240,12 @@
     <string name="eye_protection_intensity_summary">当前强度:%1$d</string>
     <string name="eye_protection_auto_night">深色模式时自动开启</string>
     <string name="eye_protection_auto_night_summary">跟随阅读界面的深色/浅色模式自动切换</string>
+    <string name="color_temperature">色温</string>
+    <string name="color_temperature_summary">当前色温:%1$d</string>
+    <string name="eye_protection_schedule">定时开启</string>
+    <string name="eye_protection_schedule_summary">仅在设定的时间段内生效</string>
+    <string name="eye_protection_start_time">开始时间</string>
+    <string name="eye_protection_end_time">结束时间</string>
 
     <!-- 标签规则 -->
     <string name="highlight_tag_config">标签规则</string>

+ 6 - 0
app/src/main/res/values-zh-rHK/strings.xml

@@ -1738,6 +1738,12 @@
     <string name="eye_protection_intensity_summary">目前強度:%1$d</string>
     <string name="eye_protection_auto_night">深色閱讀模式時自動開啟</string>
     <string name="eye_protection_auto_night_summary">跟隨閱讀介面的深色/淺色模式自動切換</string>
+    <string name="color_temperature">色溫</string>
+    <string name="color_temperature_summary">目前色溫:%1$d</string>
+    <string name="eye_protection_schedule">定時開啟</string>
+    <string name="eye_protection_schedule_summary">僅在設定的時間範圍內生效</string>
+    <string name="eye_protection_start_time">開始時間</string>
+    <string name="eye_protection_end_time">結束時間</string>
     <string name="filter_hide_in_shelf">隱藏書架中同源書籍</string>
     <string name="filter_hide_same_name_author">隱藏書架中不同源書籍</string>
     <string name="filter_show_all">顯示全部</string>

+ 6 - 0
app/src/main/res/values-zh-rTW/strings.xml

@@ -2169,6 +2169,12 @@
     <string name="eye_protection_intensity_summary">目前強度:%1$d</string>
     <string name="eye_protection_auto_night">深色閱讀模式時自動開啟</string>
     <string name="eye_protection_auto_night_summary">跟隨閱讀介面的深色/淺色模式自動切換</string>
+    <string name="color_temperature">色溫</string>
+    <string name="color_temperature_summary">目前色溫:%1$d</string>
+    <string name="eye_protection_schedule">定時開啟</string>
+    <string name="eye_protection_schedule_summary">僅在設定的時間範圍內生效</string>
+    <string name="eye_protection_start_time">開始時間</string>
+    <string name="eye_protection_end_time">結束時間</string>
     <string name="highlight_tag_config">標籤規則</string>
     <string name="import_highlight_tag_rule">匯入標籤規則</string>
     <string name="highlight_tag_title">標題</string>