mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 11:42:22 +08:00
perf: disable buildConfig
This commit is contained in:
parent
ea48edc5ac
commit
fc18ef63a2
4
.github/workflows/Build-Apk.yml
vendored
4
.github/workflows/Build-Apk.yml
vendored
|
@ -46,8 +46,8 @@ jobs:
|
|||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: default-release
|
||||
path: app/build/outputs/apk/default/release
|
||||
name: gkd-release
|
||||
path: app/build/outputs/apk/gkd/release
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
|
6
.github/workflows/Build-Release.yml
vendored
6
.github/workflows/Build-Release.yml
vendored
|
@ -39,8 +39,8 @@ jobs:
|
|||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: default-release
|
||||
path: app/build/outputs/apk/default/release
|
||||
name: gkd-release
|
||||
path: app/build/outputs/apk/gkd/release
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
@ -82,7 +82,7 @@ jobs:
|
|||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: outputs/apk/default/release/app-default-release.apk
|
||||
asset_path: outputs/apk/gkd/release/app-gkd-release.apk
|
||||
asset_name: gkd-${{ github.ref_name }}.apk
|
||||
asset_content_type: application/vnd.android.package-archive
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import com.android.build.gradle.internal.cxx.json.jsonStringOf
|
||||
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeFeatureFlag
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
fun String.runCommand(currentWorkingDir: File = file("./")): String {
|
||||
|
@ -34,6 +34,8 @@ val gitInfo = try {
|
|||
null
|
||||
}
|
||||
|
||||
val commitTime = gitInfo?.commitTime ?: 0
|
||||
val commitId = gitInfo?.commitId ?: "unknown"
|
||||
val vnSuffix = "-${gitInfo?.commitId?.substring(0, 7) ?: "unknown"}"
|
||||
|
||||
plugins {
|
||||
|
@ -64,26 +66,19 @@ android {
|
|||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
}
|
||||
|
||||
val commitTime = gitInfo?.commitTime ?: 0
|
||||
buildConfigField("Long", "GIT_COMMIT_TIME", jsonStringOf(commitTime) + "L")
|
||||
buildConfigField(
|
||||
"String",
|
||||
"GIT_COMMIT_ID",
|
||||
jsonStringOf(gitInfo?.commitId)
|
||||
)
|
||||
buildConfigField("Boolean", "ENABLED_UPDATE", jsonStringOf(true))
|
||||
resourceConfigurations.addAll(listOf("zh", "en"))
|
||||
ndk {
|
||||
// noinspection ChromeOsAbiSupport
|
||||
abiFilters += listOf("arm64-v8a", "x86_64")
|
||||
}
|
||||
|
||||
manifestPlaceholders["commitId"] = commitId
|
||||
manifestPlaceholders["commitTime"] = commitTime
|
||||
}
|
||||
|
||||
lint {}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
compose = true
|
||||
aidl = true
|
||||
}
|
||||
|
@ -109,6 +104,7 @@ android {
|
|||
}
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
isDebuggable = false
|
||||
setProguardFiles(
|
||||
listOf(
|
||||
// /sdk/tools/proguard/proguard-android-optimize.txt
|
||||
|
@ -126,12 +122,12 @@ android {
|
|||
}
|
||||
productFlavors {
|
||||
flavorDimensions += "channel"
|
||||
val defaultName = "default"
|
||||
create(defaultName) {
|
||||
create("gkd") {
|
||||
isDefault = true
|
||||
manifestPlaceholders["updateEnabled"] = true
|
||||
}
|
||||
create("foss") {
|
||||
buildConfigField("Boolean", "ENABLED_UPDATE", jsonStringOf(false))
|
||||
manifestPlaceholders["updateEnabled"] = false
|
||||
}
|
||||
all {
|
||||
dimension = flavorDimensionList.first()
|
||||
|
@ -179,8 +175,7 @@ configurations.configureEach {
|
|||
}
|
||||
|
||||
composeCompiler {
|
||||
// https://developer.android.com/develop/ui/compose/performance/stability/strongskipping?hl=zh-cn
|
||||
enableStrongSkippingMode = true
|
||||
featureFlags.addAll(ComposeFeatureFlag.StrongSkipping)
|
||||
reportsDestination = layout.buildDirectory.dir("compose_compiler")
|
||||
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
|
||||
}
|
||||
|
|
|
@ -44,6 +44,15 @@
|
|||
<meta-data
|
||||
android:name="channel"
|
||||
android:value="${channel}" />
|
||||
<meta-data
|
||||
android:name="commitId"
|
||||
android:value="${commitId}" />
|
||||
<meta-data
|
||||
android:name="commitTime"
|
||||
android:value="${commitTime}" />
|
||||
<meta-data
|
||||
android:name="updateEnabled"
|
||||
android:value="${updateEnabled}" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity
|
|||
import android.app.Application
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.database.ContentObserver
|
||||
import android.os.Build
|
||||
|
@ -17,10 +18,10 @@ import com.tencent.mmkv.MMKV
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import li.songe.gkd.data.selfAppInfo
|
||||
import li.songe.gkd.debug.clearHttpSubs
|
||||
import li.songe.gkd.notif.initChannel
|
||||
import li.songe.gkd.service.GkdAbService
|
||||
import li.songe.gkd.util.GIT_COMMIT_URL
|
||||
import li.songe.gkd.util.initAppState
|
||||
import li.songe.gkd.util.initFolder
|
||||
import li.songe.gkd.util.initStore
|
||||
|
@ -43,7 +44,17 @@ val applicationInfo by lazy {
|
|||
)
|
||||
}
|
||||
|
||||
val channel by lazy { applicationInfo.metaData.getString("channel") }
|
||||
data object META {
|
||||
val channel by lazy { applicationInfo.metaData.getString("channel")!! }
|
||||
val commitId by lazy { applicationInfo.metaData.getString("commitId")!! }
|
||||
val commitUrl by lazy { "https://github.com/gkd-kit/gkd/commit/$commitId" }
|
||||
val commitTime by lazy { applicationInfo.metaData.getLong("commitTime") }
|
||||
val updateEnabled by lazy { applicationInfo.metaData.getBoolean("updateEnabled") }
|
||||
val debuggable by lazy { applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0 }
|
||||
val versionCode by lazy { selfAppInfo.versionCode.toInt() }
|
||||
val versionName by lazy { selfAppInfo.versionName!! }
|
||||
val appId by lazy { selfAppInfo.id }
|
||||
}
|
||||
|
||||
class App : Application() {
|
||||
override fun attachBaseContext(base: Context?) {
|
||||
|
@ -69,15 +80,12 @@ class App : Application() {
|
|||
setReactiveToastStyle()
|
||||
|
||||
LogUtils.getConfig().apply {
|
||||
setConsoleSwitch(BuildConfig.DEBUG)
|
||||
setConsoleSwitch(META.debuggable)
|
||||
saveDays = 7
|
||||
isLog2FileSwitch = true
|
||||
}
|
||||
LogUtils.d(
|
||||
"GIT_COMMIT_URL: $GIT_COMMIT_URL",
|
||||
"VERSION_CODE: ${BuildConfig.VERSION_CODE}",
|
||||
"VERSION_NAME: ${BuildConfig.VERSION_NAME}",
|
||||
"CHANNEL: $channel"
|
||||
"META", META
|
||||
)
|
||||
initFolder()
|
||||
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
|
||||
|
|
|
@ -83,7 +83,7 @@ class MainActivity : ComponentActivity() {
|
|||
)
|
||||
AuthDialog(mainVm.authReasonFlow)
|
||||
BuildDialog(mainVm.dialogFlow)
|
||||
if (BuildConfig.ENABLED_UPDATE) {
|
||||
if (META.updateEnabled) {
|
||||
UpgradeDialog(mainVm.updateStatus)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class MainViewModel : ViewModel() {
|
|||
clearCache()
|
||||
}
|
||||
|
||||
if (BuildConfig.ENABLED_UPDATE && storeFlow.value.autoCheckAppUpdate) {
|
||||
if (META.updateEnabled && storeFlow.value.autoCheckAppUpdate) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
updateStatus.checkUpdate()
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.accessibilityservice.AccessibilityService
|
|||
import android.util.Log
|
||||
import android.view.accessibility.AccessibilityNodeInfo
|
||||
import kotlinx.coroutines.Job
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.META
|
||||
import li.songe.gkd.service.GkdAbService
|
||||
import li.songe.gkd.service.createCacheTransform
|
||||
import li.songe.gkd.service.createNoCacheTransform
|
||||
|
@ -273,7 +273,7 @@ private const val MIN_CACHE_INTERVAL = 2000L
|
|||
|
||||
fun clearNodeCache(t: Long = System.currentTimeMillis()) {
|
||||
lastCacheTime = t
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (META.debuggable) {
|
||||
val sizeList = defaultCacheTransform.cache.sizeList
|
||||
if (sizeList.any { it > 0 }) {
|
||||
Log.d("cache", "clear cache, sizeList=$sizeList")
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.util.LruCache
|
|||
import android.view.accessibility.AccessibilityEvent
|
||||
import android.view.accessibility.AccessibilityNodeInfo
|
||||
import com.blankj.utilcode.util.LogUtils
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.META
|
||||
import li.songe.selector.Context
|
||||
import li.songe.selector.FastQuery
|
||||
import li.songe.selector.MatchOption
|
||||
|
@ -154,7 +154,7 @@ private val typeInfo by lazy {
|
|||
|
||||
fun Selector.checkSelector(): String? {
|
||||
val error = checkType(typeInfo) ?: return null
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (META.debuggable) {
|
||||
LogUtils.d(
|
||||
"Selector check error",
|
||||
source,
|
||||
|
|
|
@ -5,7 +5,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.META
|
||||
import li.songe.gkd.app
|
||||
import li.songe.gkd.appScope
|
||||
import li.songe.gkd.data.ActivityLog
|
||||
|
@ -43,7 +43,7 @@ fun updateTopActivity(topActivity: TopActivity) {
|
|||
val isSameActivity =
|
||||
topActivityFlow.value.appId == topActivity.appId && topActivityFlow.value.activityId == topActivity.activityId
|
||||
if (isSameActivity) {
|
||||
if (isActivityVisible() && topActivity.appId == BuildConfig.APPLICATION_ID) {
|
||||
if (isActivityVisible() && topActivity.appId == META.appId) {
|
||||
return
|
||||
}
|
||||
if (topActivityFlow.value.number == topActivity.number) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import kotlinx.coroutines.flow.debounce
|
|||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.META
|
||||
import li.songe.gkd.appScope
|
||||
import li.songe.gkd.composition.CompositionAbService
|
||||
import li.songe.gkd.composition.CompositionExt.useLifeCycleLog
|
||||
|
@ -152,7 +152,7 @@ class GkdAbService : CompositionAbService({
|
|||
val size = events.size
|
||||
if (size == 0 && byEvent) return@launchTry
|
||||
val pair = if (size > 1) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (META.debuggable) {
|
||||
Log.d("latestEvent", "丢弃事件=$size")
|
||||
}
|
||||
null
|
||||
|
@ -185,7 +185,7 @@ class GkdAbService : CompositionAbService({
|
|||
false
|
||||
}
|
||||
if (!refreshOk) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (META.debuggable) {
|
||||
Log.d("latestEvent", "最新事件已过期")
|
||||
}
|
||||
latestEvent = null
|
||||
|
@ -284,7 +284,7 @@ class GkdAbService : CompositionAbService({
|
|||
}
|
||||
lastContentEventTime = fixedEvent.time
|
||||
}
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (META.debuggable) {
|
||||
Log.d(
|
||||
"AccessibilityEvent",
|
||||
"type:${event.eventType},app:${event.packageName},cls:${event.className}"
|
||||
|
|
|
@ -21,7 +21,7 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.META
|
||||
import li.songe.gkd.composition.CanOnDestroy
|
||||
import li.songe.gkd.data.DeviceInfo
|
||||
import li.songe.gkd.util.json
|
||||
|
@ -249,12 +249,12 @@ data class UserServiceWrapper(
|
|||
suspend fun newUserService(): UserServiceWrapper = suspendCoroutine { continuation ->
|
||||
val serviceArgs = Shizuku.UserServiceArgs(
|
||||
ComponentName(
|
||||
BuildConfig.APPLICATION_ID,
|
||||
META.appId,
|
||||
UserService::class.java.name
|
||||
)
|
||||
).daemon(false).processNameSuffix(
|
||||
"service-for-${if (BuildConfig.DEBUG) "gkd-debug" else "gkd-release"}"
|
||||
).debuggable(BuildConfig.DEBUG).version(BuildConfig.VERSION_CODE)
|
||||
"service-for-${if (META.debuggable) "gkd-debug" else "gkd-release"}"
|
||||
).debuggable(META.debuggable).version(META.versionCode)
|
||||
|
||||
var resumeFc: ((UserServiceWrapper) -> Unit)? = { continuation.resume(it) }
|
||||
|
||||
|
|
|
@ -23,11 +23,9 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.channel
|
||||
import li.songe.gkd.META
|
||||
import li.songe.gkd.ui.style.EmptyHeight
|
||||
import li.songe.gkd.ui.style.itemPadding
|
||||
import li.songe.gkd.util.GIT_COMMIT_URL
|
||||
import li.songe.gkd.util.LocalNavController
|
||||
import li.songe.gkd.util.ProfileTransitions
|
||||
import li.songe.gkd.util.REPOSITORY_URL
|
||||
|
@ -40,8 +38,6 @@ import li.songe.gkd.util.openUri
|
|||
fun AboutPage() {
|
||||
val navController = LocalNavController.current
|
||||
val context = LocalContext.current
|
||||
|
||||
val buildName = channel?.let { "$it-" } + BuildConfig.BUILD_TYPE
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
|
||||
Scaffold(
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
|
@ -96,7 +92,7 @@ fun AboutPage() {
|
|||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
Text(
|
||||
text = BuildConfig.VERSION_CODE.toString(),
|
||||
text = META.versionCode.toString(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
@ -111,16 +107,15 @@ fun AboutPage() {
|
|||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
Text(
|
||||
text = BuildConfig.VERSION_NAME,
|
||||
text = META.versionName,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
@Suppress("SENSELESS_COMPARISON") if (GIT_COMMIT_URL != null && BuildConfig.GIT_COMMIT_ID != null) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
context.openUri(GIT_COMMIT_URL)
|
||||
context.openUri(META.commitUrl)
|
||||
}
|
||||
.fillMaxWidth()
|
||||
.itemPadding()
|
||||
|
@ -130,12 +125,11 @@ fun AboutPage() {
|
|||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
Text(
|
||||
text = BuildConfig.GIT_COMMIT_ID,
|
||||
text = META.commitId,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
@ -146,7 +140,7 @@ fun AboutPage() {
|
|||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
Text(
|
||||
text = BuildConfig.GIT_COMMIT_TIME.format("yyyy-MM-dd HH:mm:ss ZZ"),
|
||||
text = META.commitTime.format("yyyy-MM-dd HH:mm:ss ZZ"),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
@ -158,11 +152,11 @@ fun AboutPage() {
|
|||
.itemPadding()
|
||||
) {
|
||||
Text(
|
||||
text = "构建类型",
|
||||
text = "构建渠道",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
Text(
|
||||
text = buildName,
|
||||
text = META.channel,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
|
|
@ -37,7 +37,7 @@ import androidx.lifecycle.viewModelScope
|
|||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.ramcosta.composedestinations.navigation.navigate
|
||||
import kotlinx.coroutines.flow.update
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.META
|
||||
import li.songe.gkd.MainActivity
|
||||
import li.songe.gkd.ui.component.RotatingLoadingIcon
|
||||
import li.songe.gkd.ui.component.SettingItem
|
||||
|
@ -297,7 +297,7 @@ fun useSettingsPage(): ScaffoldExt {
|
|||
})
|
||||
}
|
||||
|
||||
if (BuildConfig.ENABLED_UPDATE) {
|
||||
if (META.updateEnabled) {
|
||||
Text(
|
||||
text = "更新",
|
||||
modifier = Modifier.titleItemPadding(),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package li.songe.gkd.util
|
||||
|
||||
import android.webkit.URLUtil
|
||||
import li.songe.gkd.BuildConfig
|
||||
|
||||
const val FILE_SHORT_URL = "https://f.gkd.li/"
|
||||
const val IMPORT_SHORT_URL = "https://i.gkd.li/i/"
|
||||
|
@ -13,13 +12,6 @@ const val REPOSITORY_URL = "https://github.com/gkd-kit/gkd"
|
|||
|
||||
const val HOME_PAGE_URL = "https://gkd.li"
|
||||
|
||||
@Suppress("SENSELESS_COMPARISON")
|
||||
val GIT_COMMIT_URL = if (BuildConfig.GIT_COMMIT_ID != null) {
|
||||
"https://github.com/gkd-kit/gkd/commit/${BuildConfig.GIT_COMMIT_ID}"
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
private val safeRemoteBaseUrls = arrayOf(
|
||||
"https://registry.npmmirror.com/@gkd-kit/",
|
||||
"https://raw.githubusercontent.com/gkd-kit/",
|
||||
|
|
|
@ -9,7 +9,7 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.encodeToString
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.META
|
||||
import li.songe.gkd.appScope
|
||||
|
||||
private inline fun <reified T> createStorageFlow(
|
||||
|
@ -49,7 +49,7 @@ data class Store(
|
|||
val httpServerPort: Int = 8888,
|
||||
val updateSubsInterval: Long = UpdateTimeOption.Everyday.value,
|
||||
val captureVolumeChange: Boolean = false,
|
||||
val autoCheckAppUpdate: Boolean = BuildConfig.ENABLED_UPDATE,
|
||||
val autoCheckAppUpdate: Boolean = META.updateEnabled,
|
||||
val toastWhenClick: Boolean = true,
|
||||
val clickToast: String = "GKD",
|
||||
val autoClearMemorySubs: Boolean = true,
|
||||
|
@ -68,7 +68,7 @@ data class Store(
|
|||
val useCustomNotifText: Boolean = false,
|
||||
val customNotifText: String = "\${i}全局/\${k}应用/\${u}规则组/\${n}触发",
|
||||
val enableActivityLog: Boolean = false,
|
||||
val updateChannel: Int = if (BuildConfig.VERSION_NAME.contains("beta")) UpdateChannelOption.Beta.value else UpdateChannelOption.Stable.value,
|
||||
val updateChannel: Int = if (META.versionName.contains("beta")) UpdateChannelOption.Beta.value else UpdateChannelOption.Stable.value,
|
||||
)
|
||||
|
||||
val storeFlow by lazy {
|
||||
|
|
|
@ -31,7 +31,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.Serializable
|
||||
import li.songe.gkd.BuildConfig
|
||||
import li.songe.gkd.META
|
||||
import li.songe.gkd.MainActivity
|
||||
import li.songe.gkd.MainViewModel
|
||||
import li.songe.gkd.app
|
||||
|
@ -73,9 +73,9 @@ suspend fun UpdateStatus.checkUpdate(): NewVersion? {
|
|||
checkUpdatingFlow.value = true
|
||||
try {
|
||||
val newVersion = client.get(UPDATE_URL).body<NewVersion>()
|
||||
if (newVersion.versionCode > BuildConfig.VERSION_CODE) {
|
||||
if (newVersion.versionCode > META.versionCode) {
|
||||
newVersionFlow.value =
|
||||
newVersion.copy(versionLogs = newVersion.versionLogs.takeWhile { v -> v.code > BuildConfig.VERSION_CODE })
|
||||
newVersion.copy(versionLogs = newVersion.versionLogs.takeWhile { v -> v.code > META.versionCode })
|
||||
return newVersion
|
||||
} else {
|
||||
Log.d("Upgrade", "no new version")
|
||||
|
@ -130,7 +130,7 @@ fun UpgradeDialog(status: UpdateStatus) {
|
|||
AlertDialog(title = {
|
||||
Text(text = "新版本")
|
||||
}, text = {
|
||||
Text(text = "v${BuildConfig.VERSION_NAME} -> v${newVersionVal.versionName}\n\n${
|
||||
Text(text = "v${META.versionName} -> v${newVersionVal.versionName}\n\n${
|
||||
if (newVersionVal.versionLogs.size > 1) {
|
||||
newVersionVal.versionLogs.joinToString("\n\n") { v -> "v${v.name}\n${v.desc}" }
|
||||
} else if (newVersionVal.versionLogs.isNotEmpty()) {
|
||||
|
|
|
@ -22,7 +22,6 @@ android {
|
|||
}
|
||||
buildFeatures {
|
||||
aidl = true
|
||||
buildConfig = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user