release: v1.2.2 - add about screen, migrate update server to VPS, and optimize UI
Release OpenLoc APKs / Build & Publish Release (push) Canceled after 0s
Release OpenLoc APKs / Build & Publish Release (push) Canceled after 0s
This commit is contained in:
1 parent
32fa4a611a
commit
7b0d5b802d
16 files changed
+619
-456
No files matched your search
@@ -18,8 +18,8 @@ android {
|
||||
applicationId = "com.lzxnone.openloc"
|
||||
minSdk = 28
|
||||
targetSdk = 36
|
||||
versionCode = 4
|
||||
versionName = "1.2.1"
|
||||
versionCode = 5
|
||||
versionName = "1.2.2"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -75,6 +75,7 @@ android {
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.lzxnone.openloc.core.util
|
||||
|
||||
import com.lzxnone.openloc.BuildConfig
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.json.JSONObject
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
|
||||
@@ -10,94 +13,64 @@ import java.net.URL
|
||||
* 版本更新信息
|
||||
*/
|
||||
data class UpdateInfo(
|
||||
val hasUpdate: Boolean,
|
||||
val latestVersion: String,
|
||||
val currentVersion: String,
|
||||
val releaseTitle: String,
|
||||
val versionCode: Long,
|
||||
val versionName: String,
|
||||
val changelog: String,
|
||||
val releaseUrl: String
|
||||
)
|
||||
val downloadUrl: String,
|
||||
val apkSize: String = ""
|
||||
) {
|
||||
val hasUpdate: Boolean
|
||||
get() = versionCode > BuildConfig.VERSION_CODE
|
||||
}
|
||||
|
||||
/**
|
||||
* GitHub Releases 版本更新检查器
|
||||
* VPS 节点自建版本更新检查器
|
||||
*/
|
||||
object UpdateChecker {
|
||||
private const val GITHUB_API_URL = "https://api.github.com/repos/lzxnone/openloc/releases/latest"
|
||||
private const val UPDATE_URL = "https://update.lzxnone.cloud/openloc/version.json"
|
||||
|
||||
/**
|
||||
* 检查 GitHub 是否有新版本
|
||||
* 检查是否有新版本
|
||||
*/
|
||||
suspend fun checkUpdate(currentVersion: String = "v1.2.1"): Result<UpdateInfo> = withContext(Dispatchers.IO) {
|
||||
suspend fun checkUpdate(): Result<UpdateInfo> = withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val url = URL(GITHUB_API_URL)
|
||||
val conn = (url.openConnection() as HttpURLConnection).apply {
|
||||
requestMethod = "GET"
|
||||
val url = URL(UPDATE_URL)
|
||||
val connection = (url.openConnection() as HttpURLConnection).apply {
|
||||
connectTimeout = 8000
|
||||
readTimeout = 8000
|
||||
setRequestProperty("Accept", "application/vnd.github.v3+json")
|
||||
setRequestProperty("User-Agent", "OpenLoc-App")
|
||||
requestMethod = "GET"
|
||||
setRequestProperty("Accept", "application/json")
|
||||
setRequestProperty("User-Agent", "OpenLoc-Android")
|
||||
}
|
||||
|
||||
val code = conn.responseCode
|
||||
if (code == 200) {
|
||||
val responseText = conn.inputStream.bufferedReader().use { it.readText() }
|
||||
val json = JSONObject(responseText)
|
||||
val tagName = json.optString("tag_name", "").trim()
|
||||
val title = json.optString("name", tagName).trim()
|
||||
val body = json.optString("body", "").trim()
|
||||
val htmlUrl = json.optString("html_url", "https://github.com/lzxnone/openloc/releases").trim()
|
||||
val responseCode = connection.responseCode
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
val reader = BufferedReader(InputStreamReader(connection.inputStream, Charsets.UTF_8))
|
||||
val response = reader.use { it.readText() }
|
||||
connection.disconnect()
|
||||
|
||||
val json = JSONObject(response)
|
||||
val versionCode = json.optLong("versionCode", 0L)
|
||||
val versionName = json.optString("versionName", "")
|
||||
val changelog = json.optString("changelog", "")
|
||||
val downloadUrl = json.optString("downloadUrl", "")
|
||||
val apkSize = json.optString("apkSize", "")
|
||||
|
||||
val hasUpdate = isNewerVersion(tagName, currentVersion)
|
||||
Result.success(
|
||||
UpdateInfo(
|
||||
hasUpdate = hasUpdate,
|
||||
latestVersion = tagName.ifEmpty { currentVersion },
|
||||
currentVersion = currentVersion,
|
||||
releaseTitle = title.ifEmpty { tagName },
|
||||
changelog = body,
|
||||
releaseUrl = htmlUrl
|
||||
)
|
||||
)
|
||||
} else if (code == 404) {
|
||||
// 仓库尚未发布任何 Release 时 GitHub 会返回 404
|
||||
Result.success(
|
||||
UpdateInfo(
|
||||
hasUpdate = false,
|
||||
latestVersion = currentVersion,
|
||||
currentVersion = currentVersion,
|
||||
releaseTitle = "",
|
||||
changelog = "",
|
||||
releaseUrl = "https://github.com/lzxnone/openloc/releases"
|
||||
versionCode = versionCode,
|
||||
versionName = versionName,
|
||||
changelog = changelog,
|
||||
downloadUrl = downloadUrl,
|
||||
apkSize = apkSize
|
||||
)
|
||||
)
|
||||
} else {
|
||||
Result.failure(Exception("HTTP $code"))
|
||||
connection.disconnect()
|
||||
Result.failure(Exception("HTTP error $responseCode"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Result.failure(e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较版本号:remote > current 则返回 true
|
||||
*/
|
||||
fun isNewerVersion(remoteTag: String, currentVer: String): Boolean {
|
||||
if (remoteTag.isBlank()) return false
|
||||
val cleanRemote = remoteTag.trim().removePrefix("v").removePrefix("V")
|
||||
val cleanCurrent = currentVer.trim().removePrefix("v").removePrefix("V")
|
||||
|
||||
val remoteParts = cleanRemote.split(".").mapNotNull { it.toIntOrNull() }
|
||||
val currentParts = cleanCurrent.split(".").mapNotNull { it.toIntOrNull() }
|
||||
|
||||
if (remoteParts.isEmpty()) return false
|
||||
|
||||
val maxLen = maxOf(remoteParts.size, currentParts.size)
|
||||
for (i in 0 until maxLen) {
|
||||
val r = remoteParts.getOrElse(i) { 0 }
|
||||
val c = currentParts.getOrElse(i) { 0 }
|
||||
if (r > c) return true
|
||||
if (r < c) return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,7 @@ object AppPreferences {
|
||||
private const val KEY_ENABLE_STEALTH = "enable_stealth"
|
||||
private const val KEY_ENABLE_DEV_CAMOUFLAGE = "enable_dev_camouflage"
|
||||
private const val KEY_AUTO_CHECK_UPDATE = "auto_check_update"
|
||||
private const val KEY_SUPPRESSED_UPDATE_VERSION = "suppressed_update_version"
|
||||
|
||||
var appLanguage by mutableStateOf(AppLanguage.SYSTEM)
|
||||
private set
|
||||
@@ -129,6 +130,9 @@ object AppPreferences {
|
||||
var isAutoCheckUpdateEnabled by mutableStateOf(true)
|
||||
private set
|
||||
|
||||
var suppressedUpdateVersionCode by mutableLongStateOf(0L)
|
||||
private set
|
||||
|
||||
|
||||
var searchProvider by mutableStateOf(SearchProvider.AMAP)
|
||||
private set
|
||||
@@ -235,6 +239,7 @@ object AppPreferences {
|
||||
isStealthEnabled = prefs.getBoolean(KEY_ENABLE_STEALTH, true)
|
||||
isDevCamouflageEnabled = prefs.getBoolean(KEY_ENABLE_DEV_CAMOUFLAGE, true)
|
||||
isAutoCheckUpdateEnabled = prefs.getBoolean(KEY_AUTO_CHECK_UPDATE, true)
|
||||
suppressedUpdateVersionCode = prefs.getLong(KEY_SUPPRESSED_UPDATE_VERSION, 0L)
|
||||
|
||||
syncConfigToSystem()
|
||||
}
|
||||
@@ -560,5 +565,10 @@ object AppPreferences {
|
||||
isAutoCheckUpdateEnabled = enabled
|
||||
prefs.edit().putBoolean(KEY_AUTO_CHECK_UPDATE, enabled).apply()
|
||||
}
|
||||
|
||||
fun updateSuppressedVersionCode(code: Long) {
|
||||
suppressedUpdateVersionCode = code
|
||||
prefs.edit().putLong(KEY_SUPPRESSED_UPDATE_VERSION, code).apply()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.lzxnone.openloc.ui.components
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
@@ -18,6 +22,8 @@ import com.lzxnone.openloc.R
|
||||
@Composable
|
||||
fun OpenLocTopBar(
|
||||
title: String = stringResource(id = R.string.app_name),
|
||||
onAboutClick: () -> Unit = {},
|
||||
showAboutAction: Boolean = true,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
TopAppBar(
|
||||
@@ -29,6 +35,17 @@ fun OpenLocTopBar(
|
||||
)
|
||||
)
|
||||
},
|
||||
actions = {
|
||||
if (showAboutAction) {
|
||||
IconButton(onClick = onAboutClick) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Info,
|
||||
contentDescription = stringResource(id = R.string.section_about),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.background,
|
||||
titleContentColor = MaterialTheme.colorScheme.onBackground
|
||||
|
||||
@@ -4,18 +4,13 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.NewReleases
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
@@ -34,27 +29,25 @@ import com.lzxnone.openloc.core.util.UpdateInfo
|
||||
@Composable
|
||||
fun UpdateDialog(
|
||||
updateInfo: UpdateInfo,
|
||||
onDismiss: () -> Unit
|
||||
onDismiss: () -> Unit,
|
||||
onDontShowAgain: (Long) -> Unit = {}
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val scrollState = rememberScrollState()
|
||||
|
||||
val displayVersion = if (updateInfo.versionName.startsWith("v", ignoreCase = true)) {
|
||||
"V" + updateInfo.versionName.substring(1)
|
||||
} else {
|
||||
"V${updateInfo.versionName}"
|
||||
}
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
icon = {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.NewReleases,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
},
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(id = R.string.home_update_available_title, updateInfo.latestVersion),
|
||||
style = MaterialTheme.typography.titleLarge.copy(
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
text = stringResource(id = R.string.update_dialog_title_format, displayVersion),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
},
|
||||
text = {
|
||||
@@ -64,57 +57,47 @@ fun UpdateDialog(
|
||||
.heightIn(max = 280.dp)
|
||||
.verticalScroll(scrollState)
|
||||
) {
|
||||
if (updateInfo.releaseTitle.isNotBlank() && updateInfo.releaseTitle != updateInfo.latestVersion) {
|
||||
Text(
|
||||
text = updateInfo.releaseTitle,
|
||||
style = MaterialTheme.typography.titleMedium.copy(
|
||||
fontWeight = FontWeight.SemiBold
|
||||
),
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
|
||||
if (updateInfo.changelog.isNotBlank()) {
|
||||
Text(
|
||||
text = updateInfo.changelog,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
} else {
|
||||
Text(
|
||||
text = stringResource(id = R.string.home_update_dialog_msg),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = updateInfo.changelog,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = {
|
||||
openBrowser(context, updateInfo.releaseUrl)
|
||||
openBrowser(context, updateInfo.downloadUrl)
|
||||
onDismiss()
|
||||
}
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.home_update_btn_go))
|
||||
Text(text = stringResource(id = R.string.btn_download_update))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text(text = stringResource(id = R.string.home_update_btn_later))
|
||||
Row {
|
||||
TextButton(
|
||||
onClick = {
|
||||
onDontShowAgain(updateInfo.versionCode)
|
||||
onDismiss()
|
||||
}
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.btn_dont_show_again))
|
||||
}
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text(text = stringResource(id = R.string.action_cancel))
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun openBrowser(context: Context, url: String) {
|
||||
try {
|
||||
val targetUri = Uri.parse(url.ifBlank { "https://github.com/lzxnone/openloc/releases" })
|
||||
val intent = Intent(Intent.ACTION_VIEW, targetUri).apply {
|
||||
if (url.isBlank()) return
|
||||
runCatching {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,66 @@
|
||||
package com.lzxnone.openloc.ui.screens
|
||||
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.togetherWith
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.lzxnone.openloc.core.util.HookStatus
|
||||
import com.lzxnone.openloc.data.preference.AppPreferences
|
||||
import com.lzxnone.openloc.ui.components.OpenLocBottomBar
|
||||
import com.lzxnone.openloc.ui.components.OpenLocTopBar
|
||||
import com.lzxnone.openloc.ui.navigation.NavTab
|
||||
import com.lzxnone.openloc.ui.screens.home.HomeScreen
|
||||
import com.lzxnone.openloc.ui.screens.location.LocationScreen
|
||||
import com.lzxnone.openloc.ui.screens.settings.SettingsScreen
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.lzxnone.openloc.BuildConfig
|
||||
import com.lzxnone.openloc.R
|
||||
import com.lzxnone.openloc.core.util.HookStatus
|
||||
import com.lzxnone.openloc.core.util.UpdateChecker
|
||||
import com.lzxnone.openloc.core.util.UpdateInfo
|
||||
import com.lzxnone.openloc.data.preference.AppMockMode
|
||||
import com.lzxnone.openloc.data.preference.AppPreferences
|
||||
import com.lzxnone.openloc.ui.components.OpenLocBottomBar
|
||||
import com.lzxnone.openloc.ui.components.OpenLocTopBar
|
||||
import com.lzxnone.openloc.ui.components.UpdateDialog
|
||||
import com.lzxnone.openloc.ui.navigation.NavTab
|
||||
import com.lzxnone.openloc.ui.screens.about.AboutScreen
|
||||
import com.lzxnone.openloc.ui.screens.apps.AppSelectionScreen
|
||||
import com.lzxnone.openloc.ui.screens.home.HomeScreen
|
||||
import com.lzxnone.openloc.ui.screens.location.LocationScreen
|
||||
import com.lzxnone.openloc.ui.screens.settings.SettingsScreen
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 根容器页面:承载 TopAppBar、底部导航栏与各个 Tab 内容切换
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun MainScreen(
|
||||
modifier: Modifier = Modifier
|
||||
@@ -59,8 +69,10 @@ fun MainScreen(
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
var currentTab by rememberSaveable { mutableStateOf(NavTab.HOME) }
|
||||
var isAboutViewOpen by rememberSaveable { mutableStateOf(false) }
|
||||
var activeAppSelectionMode by rememberSaveable { mutableStateOf<AppMockMode?>(null) }
|
||||
var updateInfoToDisplay by remember { mutableStateOf<UpdateInfo?>(null) }
|
||||
var isCheckingAppUpdate by remember { mutableStateOf(false) }
|
||||
|
||||
// 响应式的总开关状态与激活状态
|
||||
val isServiceEnabled = AppPreferences.isServiceEnabled
|
||||
@@ -93,26 +105,26 @@ fun MainScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// 每次进入软件,若开启了自动检查更新,则在后台静默检测,发现新版才弹窗
|
||||
// 每次进入软件,若开启了自动检查更新,则在后台静默检测,发现新版且未被抑制才弹窗
|
||||
LaunchedEffect(Unit) {
|
||||
if (AppPreferences.isAutoCheckUpdateEnabled) {
|
||||
val result = UpdateChecker.checkUpdate(currentVersion = "v1.2.1")
|
||||
val result = UpdateChecker.checkUpdate()
|
||||
result.getOrNull()?.let { info ->
|
||||
if (info.hasUpdate) {
|
||||
if (info.hasUpdate && info.versionCode > AppPreferences.suppressedUpdateVersionCode) {
|
||||
updateInfoToDisplay = info
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val checkingUpdateText = stringResource(id = R.string.home_checking_update)
|
||||
val checkFailedText = stringResource(id = R.string.home_check_update_failed)
|
||||
val alreadyLatestText = stringResource(id = R.string.home_already_latest, "v1.2.1")
|
||||
val alreadyLatestText = stringResource(id = R.string.about_latest_version)
|
||||
|
||||
val performManualCheck: () -> Unit = {
|
||||
Toast.makeText(context, checkingUpdateText, Toast.LENGTH_SHORT).show()
|
||||
isCheckingAppUpdate = true
|
||||
coroutineScope.launch {
|
||||
val result = UpdateChecker.checkUpdate(currentVersion = "v1.2.1")
|
||||
val result = UpdateChecker.checkUpdate()
|
||||
isCheckingAppUpdate = false
|
||||
result.onSuccess { info ->
|
||||
if (info.hasUpdate) {
|
||||
updateInfoToDisplay = info
|
||||
@@ -125,107 +137,149 @@ fun MainScreen(
|
||||
}
|
||||
}
|
||||
|
||||
Box(modifier = modifier.fillMaxSize()) {
|
||||
if (isAboutViewOpen) {
|
||||
BackHandler {
|
||||
isAboutViewOpen = false
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||
topBar = {
|
||||
if (currentTab != NavTab.LOCATION) {
|
||||
OpenLocTopBar()
|
||||
}
|
||||
},
|
||||
bottomBar = {
|
||||
OpenLocBottomBar(
|
||||
currentTab = currentTab,
|
||||
onTabSelected = { currentTab = it }
|
||||
TopAppBar(
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { isAboutViewOpen = false }) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(R.string.btn_back)
|
||||
)
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.section_about),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
titleContentColor = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
)
|
||||
}
|
||||
) { innerPadding ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(bottom = innerPadding.calculateBottomPadding())
|
||||
) {
|
||||
// 1. 地图页面:一旦进入后始终常驻保活,切换 Tab 绝不销毁 MapView,零延迟、不重新加载
|
||||
var hasLoadedLocation by rememberSaveable { mutableStateOf(false) }
|
||||
if (currentTab == NavTab.LOCATION) {
|
||||
hasLoadedLocation = true
|
||||
}
|
||||
|
||||
if (hasLoadedLocation) {
|
||||
LocationScreen(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
isVisible = (currentTab == NavTab.LOCATION)
|
||||
)
|
||||
}
|
||||
|
||||
// 2. 首页 (当前 Tab 为 HOME 时展示)
|
||||
AnimatedVisibility(
|
||||
visible = currentTab == NavTab.HOME,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut(),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(top = innerPadding.calculateTopPadding()),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
HomeScreen(
|
||||
isModuleActive = isModuleActive,
|
||||
isServiceEnabled = isServiceEnabled,
|
||||
onServiceEnabledChange = { enabled ->
|
||||
AppPreferences.updateServiceEnabled(enabled)
|
||||
},
|
||||
onOpenBlacklist = { activeAppSelectionMode = AppMockMode.BLACKLIST },
|
||||
onOpenWhitelist = { activeAppSelectionMode = AppMockMode.WHITELIST },
|
||||
onCheckUpdate = performManualCheck
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 设置页 (当前 Tab 为 SETTINGS 时展示)
|
||||
AnimatedVisibility(
|
||||
visible = currentTab == NavTab.SETTINGS,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut(),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(top = innerPadding.calculateTopPadding()),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
SettingsScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 应用选择全屏浮层(黑名单 / 白名单独立管理)
|
||||
AnimatedVisibility(
|
||||
visible = activeAppSelectionMode != null,
|
||||
enter = slideInHorizontally(initialOffsetX = { it }) + fadeIn(),
|
||||
exit = slideOutHorizontally(targetOffsetX = { it }) + fadeOut(),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
activeAppSelectionMode?.let { mode ->
|
||||
AppSelectionScreen(
|
||||
mode = mode,
|
||||
onNavigateBack = { activeAppSelectionMode = null }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 新版本更新弹窗
|
||||
updateInfoToDisplay?.let { info ->
|
||||
UpdateDialog(
|
||||
updateInfo = info,
|
||||
onDismiss = { updateInfoToDisplay = null }
|
||||
AboutScreen(
|
||||
onCheckAppUpdate = performManualCheck,
|
||||
isCheckingUpdate = isCheckingAppUpdate,
|
||||
modifier = Modifier.padding(innerPadding)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Box(modifier = modifier.fillMaxSize()) {
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||
topBar = {
|
||||
if (currentTab != NavTab.LOCATION) {
|
||||
OpenLocTopBar(
|
||||
onAboutClick = { isAboutViewOpen = true }
|
||||
)
|
||||
}
|
||||
},
|
||||
bottomBar = {
|
||||
OpenLocBottomBar(
|
||||
currentTab = currentTab,
|
||||
onTabSelected = { currentTab = it }
|
||||
)
|
||||
}
|
||||
) { innerPadding ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(bottom = innerPadding.calculateBottomPadding())
|
||||
) {
|
||||
// 1. 地图页面:一旦进入后始终常驻保活,切换 Tab 绝不销毁 MapView,零延迟、不重新加载
|
||||
var hasLoadedLocation by rememberSaveable { mutableStateOf(false) }
|
||||
if (currentTab == NavTab.LOCATION) {
|
||||
hasLoadedLocation = true
|
||||
}
|
||||
|
||||
if (hasLoadedLocation) {
|
||||
LocationScreen(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
isVisible = (currentTab == NavTab.LOCATION)
|
||||
)
|
||||
}
|
||||
|
||||
// 2. 首页 (当前 Tab 为 HOME 时展示)
|
||||
AnimatedVisibility(
|
||||
visible = currentTab == NavTab.HOME,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut(),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(top = innerPadding.calculateTopPadding()),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
HomeScreen(
|
||||
isModuleActive = isModuleActive,
|
||||
isServiceEnabled = isServiceEnabled,
|
||||
onServiceEnabledChange = { enabled ->
|
||||
AppPreferences.updateServiceEnabled(enabled)
|
||||
},
|
||||
onOpenBlacklist = { activeAppSelectionMode = AppMockMode.BLACKLIST },
|
||||
onOpenWhitelist = { activeAppSelectionMode = AppMockMode.WHITELIST }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 设置页 (当前 Tab 为 SETTINGS 时展示)
|
||||
AnimatedVisibility(
|
||||
visible = currentTab == NavTab.SETTINGS,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut(),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(top = innerPadding.calculateTopPadding()),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
SettingsScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 应用选择全屏浮层(黑名单 / 白名单独立管理)
|
||||
AnimatedVisibility(
|
||||
visible = activeAppSelectionMode != null,
|
||||
enter = slideInHorizontally(initialOffsetX = { it }) + fadeIn(),
|
||||
exit = slideOutHorizontally(targetOffsetX = { it }) + fadeOut(),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
activeAppSelectionMode?.let { mode ->
|
||||
AppSelectionScreen(
|
||||
mode = mode,
|
||||
onNavigateBack = { activeAppSelectionMode = null }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 新版本更新弹窗(全局层级)
|
||||
updateInfoToDisplay?.let { info ->
|
||||
UpdateDialog(
|
||||
updateInfo = info,
|
||||
onDismiss = { updateInfoToDisplay = null },
|
||||
onDontShowAgain = { suppressedCode ->
|
||||
AppPreferences.updateSuppressedVersionCode(suppressedCode)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.lzxnone.openloc.ui.screens.about
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.Sync
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.lzxnone.openloc.BuildConfig
|
||||
import com.lzxnone.openloc.R
|
||||
|
||||
@Composable
|
||||
fun AboutScreen(
|
||||
onCheckAppUpdate: () -> Unit = {},
|
||||
isCheckingUpdate: Boolean = false,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.padding(horizontal = 24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Spacer(modifier = Modifier.height(48.dp))
|
||||
|
||||
// 软件图标
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.app_logo),
|
||||
contentDescription = stringResource(R.string.app_name),
|
||||
modifier = Modifier
|
||||
.size(100.dp)
|
||||
.clip(RoundedCornerShape(22.dp))
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(18.dp))
|
||||
|
||||
// 软件名称
|
||||
Text(
|
||||
text = stringResource(R.string.app_name),
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
|
||||
// 作者
|
||||
Text(
|
||||
text = stringResource(R.string.about_author, "lzxnone"),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(36.dp))
|
||||
|
||||
// 版本与检查更新卡片
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surface
|
||||
),
|
||||
elevation = CardDefaults.cardElevation(
|
||||
defaultElevation = 1.dp
|
||||
)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(vertical = 4.dp)) {
|
||||
// 版本
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 14.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Info,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.about_app_version),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Text(
|
||||
text = "v${BuildConfig.VERSION_NAME}",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
|
||||
HorizontalDivider(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
color = MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.5f)
|
||||
)
|
||||
|
||||
// 检查更新
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(enabled = !isCheckingUpdate) {
|
||||
onCheckAppUpdate()
|
||||
}
|
||||
.padding(horizontal = 16.dp, vertical = 14.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Sync,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.about_check_updates),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
if (isCheckingUpdate) {
|
||||
Text(
|
||||
text = stringResource(R.string.checking_updates),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ fun HomeScreen(
|
||||
onServiceEnabledChange: (Boolean) -> Unit,
|
||||
onOpenBlacklist: () -> Unit,
|
||||
onOpenWhitelist: () -> Unit,
|
||||
onCheckUpdate: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val scrollState = rememberScrollState()
|
||||
@@ -55,15 +54,5 @@ fun HomeScreen(
|
||||
onOpenBlacklist = onOpenBlacklist,
|
||||
onOpenWhitelist = onOpenWhitelist
|
||||
)
|
||||
|
||||
// 4. 版本与更新模块卡片
|
||||
VersionCard(
|
||||
versionName = "v1.2.1",
|
||||
isAutoCheckEnabled = AppPreferences.isAutoCheckUpdateEnabled,
|
||||
onAutoCheckChange = { AppPreferences.updateAutoCheckUpdateEnabled(it) },
|
||||
onCheckUpdate = onCheckUpdate
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
package com.lzxnone.openloc.ui.screens.home
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.outlined.Refresh
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.lzxnone.openloc.R
|
||||
import com.lzxnone.openloc.data.preference.AppPreferences
|
||||
|
||||
/**
|
||||
* 主页底部版本模块卡片
|
||||
* 显示应用当前版本(如 v1.0.0)、“检查更新”按钮,以及“启动时自动检查更新”开关
|
||||
*/
|
||||
@Composable
|
||||
fun VersionCard(
|
||||
versionName: String = stringResource(id = R.string.home_version_name),
|
||||
isAutoCheckEnabled: Boolean = AppPreferences.isAutoCheckUpdateEnabled,
|
||||
onAutoCheckChange: (Boolean) -> Unit = { AppPreferences.updateAutoCheckUpdateEnabled(it) },
|
||||
onCheckUpdate: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Card(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surface
|
||||
),
|
||||
elevation = CardDefaults.cardElevation(
|
||||
defaultElevation = 1.dp
|
||||
)
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
// 上半部分:版本信息与手动检查更新按钮
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp, vertical = 16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
Surface(
|
||||
shape = CircleShape,
|
||||
color = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.5f),
|
||||
modifier = Modifier.size(40.dp)
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Info,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(22.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(14.dp))
|
||||
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(id = R.string.home_version_card_title),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
Spacer(modifier = Modifier.height(2.dp))
|
||||
Text(
|
||||
text = versionName,
|
||||
style = MaterialTheme.typography.titleMedium.copy(
|
||||
fontWeight = FontWeight.Bold
|
||||
),
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
|
||||
FilledTonalButton(
|
||||
onClick = onCheckUpdate,
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = ButtonDefaults.filledTonalButtonColors(
|
||||
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||
)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Refresh,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.home_check_updates_btn),
|
||||
style = MaterialTheme.typography.labelLarge.copy(
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalDivider(
|
||||
modifier = Modifier.padding(horizontal = 20.dp),
|
||||
color = MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.4f)
|
||||
)
|
||||
|
||||
// 下半部分:自动检查更新选项(默认开启)
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp, vertical = 14.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.home_auto_check_update_title),
|
||||
style = MaterialTheme.typography.titleSmall.copy(
|
||||
fontWeight = FontWeight.SemiBold
|
||||
),
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
Spacer(modifier = Modifier.height(2.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.home_auto_check_update_desc),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
|
||||
Switch(
|
||||
checked = isAutoCheckEnabled,
|
||||
onCheckedChange = onAutoCheckChange
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.6 KiB |
@@ -171,15 +171,27 @@
|
||||
|
||||
<!-- Version & Updates -->
|
||||
<string name="home_version_card_title">Current Version</string>
|
||||
<string name="home_version_name">v1.2.1</string>
|
||||
<string name="home_version_name">v1.2.2</string>
|
||||
<string name="home_check_updates_btn">Check for Updates</string>
|
||||
<string name="home_auto_check_update_title">Auto Check on Launch</string>
|
||||
<string name="home_auto_check_update_desc">Automatically check for new releases when opening the app</string>
|
||||
<string name="home_checking_update">Checking for updates…</string>
|
||||
<string name="home_update_available_title">New Version Available: %1$s</string>
|
||||
<string name="home_update_dialog_msg">A new version of OpenLoc has been released on GitHub.</string>
|
||||
<string name="home_update_dialog_msg">A new version of OpenLoc has been released.</string>
|
||||
<string name="home_update_btn_go">Go to Update</string>
|
||||
<string name="home_update_btn_later">Later</string>
|
||||
<string name="home_check_update_failed">Failed to check for updates, please check network</string>
|
||||
<string name="home_already_latest">Already the latest version (%1$s)</string>
|
||||
|
||||
<!-- About & Updates -->
|
||||
<string name="section_about">About</string>
|
||||
<string name="btn_back">Back</string>
|
||||
<string name="about_author">Author: %1$s</string>
|
||||
<string name="about_app_version">Version</string>
|
||||
<string name="about_check_updates">Check for Updates</string>
|
||||
<string name="about_latest_version">Already up to date</string>
|
||||
<string name="checking_updates">Checking for updates…</string>
|
||||
<string name="update_dialog_title_format">New Version %1$s</string>
|
||||
<string name="btn_dont_show_again">Don\'t show again</string>
|
||||
<string name="btn_download_update">Download Update</string>
|
||||
</resources>
|
||||
@@ -171,17 +171,29 @@
|
||||
|
||||
<!-- 版本与更新 -->
|
||||
<string name="home_version_card_title">当前版本</string>
|
||||
<string name="home_version_name">v1.2.1</string>
|
||||
<string name="home_version_name">v1.2.2</string>
|
||||
<string name="home_check_updates_btn">检查更新</string>
|
||||
<string name="home_auto_check_update_title">启动时自动检查更新</string>
|
||||
<string name="home_auto_check_update_desc">每次进入软件自动联网检测 GitHub 最新版本</string>
|
||||
<string name="home_auto_check_update_desc">每次进入软件自动联网检测最新版本</string>
|
||||
<string name="home_checking_update">正在检查更新…</string>
|
||||
<string name="home_update_available_title">发现新版本: %1$s</string>
|
||||
<string name="home_update_dialog_msg">OpenLoc 已在 GitHub 发布最新版本,欢迎前往下载更新。</string>
|
||||
<string name="home_update_dialog_msg">OpenLoc 已发布最新版本,欢迎前往下载更新。</string>
|
||||
<string name="home_update_btn_go">前往更新</string>
|
||||
<string name="home_update_btn_later">稍后</string>
|
||||
<string name="home_check_update_failed">检查更新失败,请检查网络</string>
|
||||
<string name="home_already_latest">当前已是最新版本 (%1$s)</string>
|
||||
|
||||
<!-- 关于与更新 -->
|
||||
<string name="section_about">关于</string>
|
||||
<string name="btn_back">返回</string>
|
||||
<string name="about_author">作者:%1$s</string>
|
||||
<string name="about_app_version">版本</string>
|
||||
<string name="about_check_updates">检查更新</string>
|
||||
<string name="about_latest_version">当前已是最新版本</string>
|
||||
<string name="checking_updates">正在检查更新…</string>
|
||||
<string name="update_dialog_title_format">新版本 %1$s</string>
|
||||
<string name="btn_dont_show_again">不再显示</string>
|
||||
<string name="btn_download_update">下载更新</string>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -171,17 +171,29 @@
|
||||
|
||||
<!-- 版本与更新 -->
|
||||
<string name="home_version_card_title">当前版本</string>
|
||||
<string name="home_version_name">v1.2.1</string>
|
||||
<string name="home_version_name">v1.2.2</string>
|
||||
<string name="home_check_updates_btn">检查更新</string>
|
||||
<string name="home_auto_check_update_title">启动时自动检查更新</string>
|
||||
<string name="home_auto_check_update_desc">每次进入软件自动联网检测 GitHub 最新版本</string>
|
||||
<string name="home_auto_check_update_desc">每次进入软件自动联网检测最新版本</string>
|
||||
<string name="home_checking_update">正在检查更新…</string>
|
||||
<string name="home_update_available_title">发现新版本: %1$s</string>
|
||||
<string name="home_update_dialog_msg">OpenLoc 已在 GitHub 发布最新版本,欢迎前往下载更新。</string>
|
||||
<string name="home_update_dialog_msg">OpenLoc 已发布最新版本,欢迎前往下载更新。</string>
|
||||
<string name="home_update_btn_go">前往更新</string>
|
||||
<string name="home_update_btn_later">稍后</string>
|
||||
<string name="home_check_update_failed">检查更新失败,请检查网络</string>
|
||||
<string name="home_already_latest">当前已是最新版本 (%1$s)</string>
|
||||
|
||||
<!-- 关于与更新 -->
|
||||
<string name="section_about">关于</string>
|
||||
<string name="btn_back">返回</string>
|
||||
<string name="about_author">作者:%1$s</string>
|
||||
<string name="about_app_version">版本</string>
|
||||
<string name="about_check_updates">检查更新</string>
|
||||
<string name="about_latest_version">当前已是最新版本</string>
|
||||
<string name="checking_updates">正在检查更新…</string>
|
||||
<string name="update_dialog_title_format">新版本 %1$s</string>
|
||||
<string name="btn_dont_show_again">不再显示</string>
|
||||
<string name="btn_download_update">下载更新</string>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -171,15 +171,27 @@
|
||||
|
||||
<!-- Version & Updates -->
|
||||
<string name="home_version_card_title">Current Version</string>
|
||||
<string name="home_version_name">v1.2.1</string>
|
||||
<string name="home_version_name">v1.2.2</string>
|
||||
<string name="home_check_updates_btn">Check for Updates</string>
|
||||
<string name="home_auto_check_update_title">Auto Check on Launch</string>
|
||||
<string name="home_auto_check_update_desc">Automatically check for new releases when opening the app</string>
|
||||
<string name="home_checking_update">Checking for updates…</string>
|
||||
<string name="home_update_available_title">New Version Available: %1$s</string>
|
||||
<string name="home_update_dialog_msg">A new version of OpenLoc has been released on GitHub.</string>
|
||||
<string name="home_update_dialog_msg">A new version of OpenLoc has been released.</string>
|
||||
<string name="home_update_btn_go">Go to Update</string>
|
||||
<string name="home_update_btn_later">Later</string>
|
||||
<string name="home_check_update_failed">Failed to check for updates, please check network</string>
|
||||
<string name="home_already_latest">Already the latest version (%1$s)</string>
|
||||
|
||||
<!-- About & Updates -->
|
||||
<string name="section_about">About</string>
|
||||
<string name="btn_back">Back</string>
|
||||
<string name="about_author">Author: %1$s</string>
|
||||
<string name="about_app_version">Version</string>
|
||||
<string name="about_check_updates">Check for Updates</string>
|
||||
<string name="about_latest_version">Already up to date</string>
|
||||
<string name="checking_updates">Checking for updates…</string>
|
||||
<string name="update_dialog_title_format">New Version %1$s</string>
|
||||
<string name="btn_dont_show_again">Don\'t show again</string>
|
||||
<string name="btn_download_update">Download Update</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user