Skip to content

Commit 6ecd63e

Browse files
committed
release
1 parent f120cc1 commit 6ecd63e

3 files changed

Lines changed: 12 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
3. 内置微软TTS支持设置音高。
44
4. 支持相同朗读目标的配置多选,并随机轮播。(右上角开启)
55
5. 将Server和系统TTS整合到一个界面,通过左侧滑抽屉菜单切换。
6-
6. 系统TTS配置的列表按旁白/对话分组。
6+
6. 系统TTS配置的列表按旁白/对话分组。

app/src/main/java/com/github/jing332/tts_server_android/ui/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class MainActivity : AppCompatActivity() {
106106
}
107107
)
108108
navController.graph = navGraph
109+
110+
MyTools.checkUpdate(this)
109111
}
110112

111113
override fun onCreateOptionsMenu(menu: Menu): Boolean {

app/src/main/java/com/github/jing332/tts_server_android/util/MyTools.kt

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.github.jing332.tts_server_android.util
33
import android.annotation.SuppressLint
44
import android.app.PendingIntent
55
import android.content.Context
6-
import android.content.DialogInterface
76
import android.content.Intent
87
import android.content.pm.ShortcutInfo
98
import android.content.pm.ShortcutManager
@@ -13,42 +12,33 @@ import android.os.Build
1312
import android.util.Log
1413
import android.widget.Toast
1514
import androidx.appcompat.app.AlertDialog
15+
import com.drake.net.Net
1616
import com.github.jing332.tts_server_android.App
1717
import com.github.jing332.tts_server_android.R
1818
import com.github.jing332.tts_server_android.bean.GithubReleaseApiBean
1919
import kotlinx.coroutines.DelicateCoroutinesApi
20+
import kotlinx.coroutines.Dispatchers
2021
import kotlinx.coroutines.GlobalScope
2122
import kotlinx.coroutines.launch
2223
import kotlinx.serialization.decodeFromString
23-
import kotlinx.serialization.json.Json
24-
import tts_server_lib.Tts_server_lib
24+
import okhttp3.Response
2525
import java.math.BigDecimal
2626

2727

2828
object MyTools {
2929
const val TAG = "MyTools"
30+
private const val GITHUB_RELEASES_LATEST_URL =
31+
"https://api.github.com/repos/jing332/tts-server-android/releases/latest"
3032
private val json by lazy { App.jsonBuilder }
3133

3234
/*从Github检查更新*/
3335
@OptIn(DelicateCoroutinesApi::class)
3436
fun checkUpdate(ctx: Context) {
35-
GlobalScope.launch {
37+
GlobalScope.launch(Dispatchers.IO) {
3638
try {
37-
val data = Tts_server_lib.httpGet(
38-
"https://api.github.com/repos/jing332/tts-server-android/releases/latest",
39-
""
40-
)
41-
if (data == null) {
42-
ctx.toast(R.string.check_update_failed)
43-
} else {
44-
try {
45-
checkVersionFromJson(ctx, data.decodeToString())
46-
} catch (e: Exception) {
47-
e.printStackTrace()
48-
ctx.toast(R.string.check_update_failed)
49-
}
50-
}
51-
39+
val resp: Response = Net.get(GITHUB_RELEASES_LATEST_URL).execute()
40+
val jsonStr = resp.body?.string()
41+
checkVersionFromJson(ctx, jsonStr!!)
5242
} catch (e: Exception) {
5343
e.printStackTrace()
5444
ctx.toast(R.string.check_update_failed)

0 commit comments

Comments
 (0)