Skip to content

Commit 27ed9a1

Browse files
authored
replaced the deprecated clickable text
1 parent 3eb52de commit 27ed9a1

File tree

8 files changed

+41
-139
lines changed

8 files changed

+41
-139
lines changed

app/src/main/java/io/github/fate_grand_automata/ui/onboarding/HighlightedText.kt

Lines changed: 0 additions & 118 deletions
This file was deleted.

app/src/main/java/io/github/fate_grand_automata/ui/onboarding/OnboardingItems.kt

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ import androidx.compose.runtime.setValue
2525
import androidx.compose.ui.Modifier
2626
import androidx.compose.ui.platform.LocalContext
2727
import androidx.compose.ui.res.stringResource
28+
import androidx.compose.ui.text.LinkAnnotation
29+
import androidx.compose.ui.text.SpanStyle
30+
import androidx.compose.ui.text.TextLinkStyles
31+
import androidx.compose.ui.text.buildAnnotatedString
32+
import androidx.compose.ui.text.style.TextDecoration
33+
import androidx.compose.ui.text.withLink
2834
import androidx.compose.ui.unit.dp
2935
import androidx.core.os.LocaleListCompat
3036
import io.github.fate_grand_automata.BuildConfig
@@ -186,8 +192,6 @@ class DisableBatteryOptimization(vm: OnboardingViewModel) : OnboardingItem(vm) {
186192
text = stringResource(R.string.p_battery_optimization_description),
187193
style = MaterialTheme.typography.bodyLarge
188194
)
189-
190-
val context = LocalContext.current
191195
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {
192196
onFinished()
193197
}
@@ -205,20 +209,36 @@ class DisableBatteryOptimization(vm: OnboardingViewModel) : OnboardingItem(vm) {
205209
)
206210
}
207211

208-
HighlightedText(
209-
text = String.format(
210-
stringResource(R.string.p_battery_optimization_dontkillmyapp),
211-
stringResource(R.string.link_dontkillmyapp)
212-
),
213-
highlights = listOf(
214-
Highlight(
215-
text = "dontkillmyapp.com",
216-
data = stringResource(R.string.link_dontkillmyapp),
217-
onClick = { link ->
218-
context.openLinkIntent(link)
219-
}
212+
Text(
213+
text = buildAnnotatedString {
214+
val linkText = stringResource(R.string.link_dontkillmyapp)
215+
val warningText = stringResource(
216+
R.string.p_battery_optimization_dontkillmyapp,
217+
linkText
218+
).split(
219+
// Split while keeping the delimiter
220+
Regex("(?<=$linkText)|(?=$linkText)")
220221
)
221-
),
222+
warningText.forEach { text ->
223+
if (text == linkText) {
224+
withLink(
225+
LinkAnnotation.Url(
226+
url = linkText,
227+
styles = TextLinkStyles(
228+
style = SpanStyle(
229+
color = MaterialTheme.colorScheme.tertiary,
230+
textDecoration = TextDecoration.Underline
231+
)
232+
)
233+
)
234+
) {
235+
append(linkText)
236+
}
237+
} else {
238+
append(text)
239+
}
240+
}
241+
},
222242
style = MaterialTheme.typography.bodyLarge
223243
)
224244
}

app/src/main/res/values-b+zh+CN/localized.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ Order Change"</string>
385385

386386
在点击下方按钮后,将应用程序筛选器由“未优化”切换到“所有应用”,并将下方FGA设置变更为“不优化”"</string>
387387
<string name="p_battery_optimization_action">"关闭电池优化"</string>
388-
<string name="p_battery_optimization_dontkillmyapp">"取决于您的设备,您可能还需要禁用更多的优化设置。您可以在dontkillmyapp.com(英文页面)上找到更多教程"</string>
388+
<string name="p_battery_optimization_dontkillmyapp">"取决于您的设备,您可能还需要禁用更多的优化设置。您可以在%s(英文页面)上找到更多教程"</string>
389389
<string name="p_youtube_guide">"Youtube教学视频"</string>
390390
<string name="p_youtube_guide_description">"推荐您观看教学视频,它将指导您如何设置周回脚本(英语视频,需要科学上网)"</string>
391391
<string name="p_youtube_guide_action">"打开教学视频"</string>

app/src/main/res/values-b+zh+TW/localized.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ Order Change"</string>
381381

382382
點選按鈕後,請選擇 FGA 並將設定調整為「不進行最佳化」"</string>
383383
<string name="p_battery_optimization_action">"關閉電池效能最佳化(系統設定)"</string>
384-
<string name="p_battery_optimization_dontkillmyapp">"您可能需要調整更多對於您裝置的效能最佳化選項。請參考 dontkillmyapp.com"</string>
384+
<string name="p_battery_optimization_dontkillmyapp">"您可能需要調整更多對於您裝置的效能最佳化選項。請參考 %s"</string>
385385
<string name="p_youtube_guide">"Youtube 教學"</string>
386386
<string name="p_youtube_guide_description">"請參考此 Youtube 教學影片以認識如何新增自動腳本"</string>
387387
<string name="p_youtube_guide_action">"至 Youtube 觀看"</string>

app/src/main/res/values-ja/localized.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@
391391

392392
ボタンを押した後、アプリフィルターを「最近開いたアプリ」から「すべてのアプリ」に切り替え、FGAを「制限なし」に設定してください。"</string>
393393
<string name="p_battery_optimization_action">"バッテリー使用最適化が無効"</string>
394-
<string name="p_battery_optimization_dontkillmyapp">"また、お使いのデバイス固有の最適化を無効にする必要があるかもしれません。ガイドはdontkillmyapp.comでご覧いただけます。"</string>
394+
<string name="p_battery_optimization_dontkillmyapp">"また、お使いのデバイス固有の最適化を無効にする必要があるかもしれません。ガイドは%sでご覧いただけます。"</string>
395395
<string name="p_youtube_guide">"Youtube ガイド"</string>
396396
<string name="p_youtube_guide_description">"Youtube ガイドを見ることをお勧めします。このビデオで設定方法を教えてくれます。"</string>
397397
<string name="p_youtube_guide_action">"ガイドを開く"</string>

app/src/main/res/values-ko/localized.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@
378378

379379
아래 버튼을 누르신 후 필터에서 \"최적화 안 함\" 대신 \"모든 앱\"을 선택 후 FGA를 눌러서 최적화 안 함을 선택해주세요."</string>
380380
<string name="p_battery_optimization_action">"배터리 최적화 비활성화"</string>
381-
<string name="p_battery_optimization_dontkillmyapp">"간혹 어떤 기종의 장비에서는 추가적으로 다른 최적화들을 비활성해야할 수 있습니다. 관련 설명은 dontkillmyapp.com (영어)에서 확인하실 수 있습니다."</string>
381+
<string name="p_battery_optimization_dontkillmyapp">"간혹 어떤 기종의 장비에서는 추가적으로 다른 최적화들을 비활성해야할 수 있습니다. 관련 설명은 %s (영어)에서 확인하실 수 있습니다."</string>
382382
<string name="p_youtube_guide">"유튜브 가이드 영상"</string>
383383
<string name="p_youtube_guide_description">"파밍 설정 방법을 알려드리는 유튜브 영상(영어)이 있으니 확인해보시는 걸 추천드립니다."</string>
384384
<string name="p_youtube_guide_action">"가이드 열기 (영어)"</string>

app/src/main/res/values-vi/localized.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ Vui lòng bật khả năng truy cập cho ứng dụng này từ cài đặt H
379379

380380
Sau khi nhấn nút, hãy chuyển bộ lọc ứng dụng từ \"Không được tối ưu hóa\" sang \"Tất cả ứng dụng\" và đặt FGA thành \"Không tối ưu hóa\"."</string>
381381
<string name="p_battery_optimization_action">"Vô hiệu hóa tối ưu hóa pin"</string>
382-
<string name="p_battery_optimization_dontkillmyapp">"Bạn cũng có thể cần phải tắt nhiều tối ưu hóa cụ thể hơn cho thiết bị của mình. Hướng dẫn có sẵn trên dontkillmyapp.com."</string>
382+
<string name="p_battery_optimization_dontkillmyapp">"Bạn cũng có thể cần phải tắt nhiều tối ưu hóa cụ thể hơn cho thiết bị của mình. Hướng dẫn có sẵn trên %s."</string>
383383
<string name="p_youtube_guide">"Hướng dẫn trên Youtube"</string>
384384
<string name="p_youtube_guide_description">"Bạn nên xem hướng dẫn Youtube vì nó sẽ hướng dẫn bạn cách thiết lập cấu hình khi farm."</string>
385385
<string name="p_youtube_guide_action">"Mở hướng dẫn"</string>

app/src/main/res/values/localized.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ Please turn on accessibility for this app from System settings. If it is already
379379

380380
After pressing on the button, switch the app filter from \"Not optimized\" to \"All apps\" and set FGA to \"Do not optimize\"."</string>
381381
<string name="p_battery_optimization_action">"Disable battery optimization"</string>
382-
<string name="p_battery_optimization_dontkillmyapp">"You may also need to disable more optimizations specific to your device. Guides are available on dontkillmyapp.com."</string>
382+
<string name="p_battery_optimization_dontkillmyapp">"You may also need to disable more optimizations specific to your device. Guides are available on %s."</string>
383383
<string name="p_youtube_guide">"Youtube guide"</string>
384384
<string name="p_youtube_guide_description">"It's recommended to watch the Youtube guide as it will teach you how to set up farming configurations."</string>
385385
<string name="p_youtube_guide_action">"Open guide"</string>

0 commit comments

Comments
 (0)