perf: disable buildConfig

This commit is contained in:
lisonge 2024-09-09 21:17:03 +08:00
parent ea48edc5ac
commit fc18ef63a2
19 changed files with 88 additions and 91 deletions

View File

@ -46,8 +46,8 @@ jobs:
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: default-release name: gkd-release
path: app/build/outputs/apk/default/release path: app/build/outputs/apk/gkd/release
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:

View File

@ -39,8 +39,8 @@ jobs:
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: default-release name: gkd-release
path: app/build/outputs/apk/default/release path: app/build/outputs/apk/gkd/release
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
@ -82,7 +82,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} 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_name: gkd-${{ github.ref_name }}.apk
asset_content_type: application/vnd.android.package-archive asset_content_type: application/vnd.android.package-archive

View File

@ -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 import java.io.ByteArrayOutputStream
fun String.runCommand(currentWorkingDir: File = file("./")): String { fun String.runCommand(currentWorkingDir: File = file("./")): String {
@ -34,6 +34,8 @@ val gitInfo = try {
null null
} }
val commitTime = gitInfo?.commitTime ?: 0
val commitId = gitInfo?.commitId ?: "unknown"
val vnSuffix = "-${gitInfo?.commitId?.substring(0, 7) ?: "unknown"}" val vnSuffix = "-${gitInfo?.commitId?.substring(0, 7) ?: "unknown"}"
plugins { plugins {
@ -64,26 +66,19 @@ android {
vectorDrawables { vectorDrawables {
useSupportLibrary = true 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")) resourceConfigurations.addAll(listOf("zh", "en"))
ndk { ndk {
// noinspection ChromeOsAbiSupport // noinspection ChromeOsAbiSupport
abiFilters += listOf("arm64-v8a", "x86_64") abiFilters += listOf("arm64-v8a", "x86_64")
} }
manifestPlaceholders["commitId"] = commitId
manifestPlaceholders["commitTime"] = commitTime
} }
lint {} lint {}
buildFeatures { buildFeatures {
buildConfig = true
compose = true compose = true
aidl = true aidl = true
} }
@ -109,6 +104,7 @@ android {
} }
isMinifyEnabled = true isMinifyEnabled = true
isShrinkResources = true isShrinkResources = true
isDebuggable = false
setProguardFiles( setProguardFiles(
listOf( listOf(
// /sdk/tools/proguard/proguard-android-optimize.txt // /sdk/tools/proguard/proguard-android-optimize.txt
@ -126,12 +122,12 @@ android {
} }
productFlavors { productFlavors {
flavorDimensions += "channel" flavorDimensions += "channel"
val defaultName = "default" create("gkd") {
create(defaultName) {
isDefault = true isDefault = true
manifestPlaceholders["updateEnabled"] = true
} }
create("foss") { create("foss") {
buildConfigField("Boolean", "ENABLED_UPDATE", jsonStringOf(false)) manifestPlaceholders["updateEnabled"] = false
} }
all { all {
dimension = flavorDimensionList.first() dimension = flavorDimensionList.first()
@ -179,8 +175,7 @@ configurations.configureEach {
} }
composeCompiler { composeCompiler {
// https://developer.android.com/develop/ui/compose/performance/stability/strongskipping?hl=zh-cn featureFlags.addAll(ComposeFeatureFlag.StrongSkipping)
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler") reportsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf") stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
} }

View File

@ -44,6 +44,15 @@
<meta-data <meta-data
android:name="channel" android:name="channel"
android:value="${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 <activity
android:name=".MainActivity" android:name=".MainActivity"

View File

@ -4,6 +4,7 @@ import android.app.Activity
import android.app.Application import android.app.Application
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.database.ContentObserver import android.database.ContentObserver
import android.os.Build import android.os.Build
@ -17,10 +18,10 @@ import com.tencent.mmkv.MMKV
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope import kotlinx.coroutines.MainScope
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import li.songe.gkd.data.selfAppInfo
import li.songe.gkd.debug.clearHttpSubs import li.songe.gkd.debug.clearHttpSubs
import li.songe.gkd.notif.initChannel import li.songe.gkd.notif.initChannel
import li.songe.gkd.service.GkdAbService 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.initAppState
import li.songe.gkd.util.initFolder import li.songe.gkd.util.initFolder
import li.songe.gkd.util.initStore 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() { class App : Application() {
override fun attachBaseContext(base: Context?) { override fun attachBaseContext(base: Context?) {
@ -69,15 +80,12 @@ class App : Application() {
setReactiveToastStyle() setReactiveToastStyle()
LogUtils.getConfig().apply { LogUtils.getConfig().apply {
setConsoleSwitch(BuildConfig.DEBUG) setConsoleSwitch(META.debuggable)
saveDays = 7 saveDays = 7
isLog2FileSwitch = true isLog2FileSwitch = true
} }
LogUtils.d( LogUtils.d(
"GIT_COMMIT_URL: $GIT_COMMIT_URL", "META", META
"VERSION_CODE: ${BuildConfig.VERSION_CODE}",
"VERSION_NAME: ${BuildConfig.VERSION_NAME}",
"CHANNEL: $channel"
) )
initFolder() initFolder()
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks { registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {

View File

@ -83,7 +83,7 @@ class MainActivity : ComponentActivity() {
) )
AuthDialog(mainVm.authReasonFlow) AuthDialog(mainVm.authReasonFlow)
BuildDialog(mainVm.dialogFlow) BuildDialog(mainVm.dialogFlow)
if (BuildConfig.ENABLED_UPDATE) { if (META.updateEnabled) {
UpgradeDialog(mainVm.updateStatus) UpgradeDialog(mainVm.updateStatus)
} }
} }

View File

@ -66,7 +66,7 @@ class MainViewModel : ViewModel() {
clearCache() clearCache()
} }
if (BuildConfig.ENABLED_UPDATE && storeFlow.value.autoCheckAppUpdate) { if (META.updateEnabled && storeFlow.value.autoCheckAppUpdate) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
try { try {
updateStatus.checkUpdate() updateStatus.checkUpdate()

View File

@ -4,7 +4,7 @@ import android.accessibilityservice.AccessibilityService
import android.util.Log import android.util.Log
import android.view.accessibility.AccessibilityNodeInfo import android.view.accessibility.AccessibilityNodeInfo
import kotlinx.coroutines.Job 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.GkdAbService
import li.songe.gkd.service.createCacheTransform import li.songe.gkd.service.createCacheTransform
import li.songe.gkd.service.createNoCacheTransform import li.songe.gkd.service.createNoCacheTransform
@ -273,7 +273,7 @@ private const val MIN_CACHE_INTERVAL = 2000L
fun clearNodeCache(t: Long = System.currentTimeMillis()) { fun clearNodeCache(t: Long = System.currentTimeMillis()) {
lastCacheTime = t lastCacheTime = t
if (BuildConfig.DEBUG) { if (META.debuggable) {
val sizeList = defaultCacheTransform.cache.sizeList val sizeList = defaultCacheTransform.cache.sizeList
if (sizeList.any { it > 0 }) { if (sizeList.any { it > 0 }) {
Log.d("cache", "clear cache, sizeList=$sizeList") Log.d("cache", "clear cache, sizeList=$sizeList")

View File

@ -6,7 +6,7 @@ import android.util.LruCache
import android.view.accessibility.AccessibilityEvent import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo import android.view.accessibility.AccessibilityNodeInfo
import com.blankj.utilcode.util.LogUtils 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.Context
import li.songe.selector.FastQuery import li.songe.selector.FastQuery
import li.songe.selector.MatchOption import li.songe.selector.MatchOption
@ -154,7 +154,7 @@ private val typeInfo by lazy {
fun Selector.checkSelector(): String? { fun Selector.checkSelector(): String? {
val error = checkType(typeInfo) ?: return null val error = checkType(typeInfo) ?: return null
if (BuildConfig.DEBUG) { if (META.debuggable) {
LogUtils.d( LogUtils.d(
"Selector check error", "Selector check error",
source, source,

View File

@ -5,7 +5,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import li.songe.gkd.BuildConfig import li.songe.gkd.META
import li.songe.gkd.app import li.songe.gkd.app
import li.songe.gkd.appScope import li.songe.gkd.appScope
import li.songe.gkd.data.ActivityLog import li.songe.gkd.data.ActivityLog
@ -43,7 +43,7 @@ fun updateTopActivity(topActivity: TopActivity) {
val isSameActivity = val isSameActivity =
topActivityFlow.value.appId == topActivity.appId && topActivityFlow.value.activityId == topActivity.activityId topActivityFlow.value.appId == topActivity.appId && topActivityFlow.value.activityId == topActivity.activityId
if (isSameActivity) { if (isSameActivity) {
if (isActivityVisible() && topActivity.appId == BuildConfig.APPLICATION_ID) { if (isActivityVisible() && topActivity.appId == META.appId) {
return return
} }
if (topActivityFlow.value.number == topActivity.number) { if (topActivityFlow.value.number == topActivity.number) {

View File

@ -26,7 +26,7 @@ import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.update import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import li.songe.gkd.BuildConfig import li.songe.gkd.META
import li.songe.gkd.appScope import li.songe.gkd.appScope
import li.songe.gkd.composition.CompositionAbService import li.songe.gkd.composition.CompositionAbService
import li.songe.gkd.composition.CompositionExt.useLifeCycleLog import li.songe.gkd.composition.CompositionExt.useLifeCycleLog
@ -152,7 +152,7 @@ class GkdAbService : CompositionAbService({
val size = events.size val size = events.size
if (size == 0 && byEvent) return@launchTry if (size == 0 && byEvent) return@launchTry
val pair = if (size > 1) { val pair = if (size > 1) {
if (BuildConfig.DEBUG) { if (META.debuggable) {
Log.d("latestEvent", "丢弃事件=$size") Log.d("latestEvent", "丢弃事件=$size")
} }
null null
@ -185,7 +185,7 @@ class GkdAbService : CompositionAbService({
false false
} }
if (!refreshOk) { if (!refreshOk) {
if (BuildConfig.DEBUG) { if (META.debuggable) {
Log.d("latestEvent", "最新事件已过期") Log.d("latestEvent", "最新事件已过期")
} }
latestEvent = null latestEvent = null
@ -284,7 +284,7 @@ class GkdAbService : CompositionAbService({
} }
lastContentEventTime = fixedEvent.time lastContentEventTime = fixedEvent.time
} }
if (BuildConfig.DEBUG) { if (META.debuggable) {
Log.d( Log.d(
"AccessibilityEvent", "AccessibilityEvent",
"type:${event.eventType},app:${event.packageName},cls:${event.className}" "type:${event.eventType},app:${event.packageName},cls:${event.className}"

View File

@ -21,7 +21,7 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import li.songe.gkd.BuildConfig import li.songe.gkd.META
import li.songe.gkd.composition.CanOnDestroy import li.songe.gkd.composition.CanOnDestroy
import li.songe.gkd.data.DeviceInfo import li.songe.gkd.data.DeviceInfo
import li.songe.gkd.util.json import li.songe.gkd.util.json
@ -249,12 +249,12 @@ data class UserServiceWrapper(
suspend fun newUserService(): UserServiceWrapper = suspendCoroutine { continuation -> suspend fun newUserService(): UserServiceWrapper = suspendCoroutine { continuation ->
val serviceArgs = Shizuku.UserServiceArgs( val serviceArgs = Shizuku.UserServiceArgs(
ComponentName( ComponentName(
BuildConfig.APPLICATION_ID, META.appId,
UserService::class.java.name UserService::class.java.name
) )
).daemon(false).processNameSuffix( ).daemon(false).processNameSuffix(
"service-for-${if (BuildConfig.DEBUG) "gkd-debug" else "gkd-release"}" "service-for-${if (META.debuggable) "gkd-debug" else "gkd-release"}"
).debuggable(BuildConfig.DEBUG).version(BuildConfig.VERSION_CODE) ).debuggable(META.debuggable).version(META.versionCode)
var resumeFc: ((UserServiceWrapper) -> Unit)? = { continuation.resume(it) } var resumeFc: ((UserServiceWrapper) -> Unit)? = { continuation.resume(it) }

View File

@ -23,11 +23,9 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootNavGraph import com.ramcosta.composedestinations.annotation.RootNavGraph
import li.songe.gkd.BuildConfig import li.songe.gkd.META
import li.songe.gkd.channel
import li.songe.gkd.ui.style.EmptyHeight import li.songe.gkd.ui.style.EmptyHeight
import li.songe.gkd.ui.style.itemPadding 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.LocalNavController
import li.songe.gkd.util.ProfileTransitions import li.songe.gkd.util.ProfileTransitions
import li.songe.gkd.util.REPOSITORY_URL import li.songe.gkd.util.REPOSITORY_URL
@ -40,8 +38,6 @@ import li.songe.gkd.util.openUri
fun AboutPage() { fun AboutPage() {
val navController = LocalNavController.current val navController = LocalNavController.current
val context = LocalContext.current val context = LocalContext.current
val buildName = channel?.let { "$it-" } + BuildConfig.BUILD_TYPE
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior() val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
Scaffold( Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
@ -96,7 +92,7 @@ fun AboutPage() {
style = MaterialTheme.typography.bodyLarge, style = MaterialTheme.typography.bodyLarge,
) )
Text( Text(
text = BuildConfig.VERSION_CODE.toString(), text = META.versionCode.toString(),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
) )
@ -111,16 +107,15 @@ fun AboutPage() {
style = MaterialTheme.typography.bodyLarge, style = MaterialTheme.typography.bodyLarge,
) )
Text( Text(
text = BuildConfig.VERSION_NAME, text = META.versionName,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
) )
} }
@Suppress("SENSELESS_COMPARISON") if (GIT_COMMIT_URL != null && BuildConfig.GIT_COMMIT_ID != null) {
Column( Column(
modifier = Modifier modifier = Modifier
.clickable { .clickable {
context.openUri(GIT_COMMIT_URL) context.openUri(META.commitUrl)
} }
.fillMaxWidth() .fillMaxWidth()
.itemPadding() .itemPadding()
@ -130,12 +125,11 @@ fun AboutPage() {
style = MaterialTheme.typography.bodyLarge, style = MaterialTheme.typography.bodyLarge,
) )
Text( Text(
text = BuildConfig.GIT_COMMIT_ID, text = META.commitId,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
) )
} }
}
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@ -146,7 +140,7 @@ fun AboutPage() {
style = MaterialTheme.typography.bodyLarge, style = MaterialTheme.typography.bodyLarge,
) )
Text( 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, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
) )
@ -158,11 +152,11 @@ fun AboutPage() {
.itemPadding() .itemPadding()
) { ) {
Text( Text(
text = "构建类型", text = "构建渠道",
style = MaterialTheme.typography.bodyLarge, style = MaterialTheme.typography.bodyLarge,
) )
Text( Text(
text = buildName, text = META.channel,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
) )

View File

@ -37,7 +37,7 @@ import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.compose.viewModel import androidx.lifecycle.viewmodel.compose.viewModel
import com.ramcosta.composedestinations.navigation.navigate import com.ramcosta.composedestinations.navigation.navigate
import kotlinx.coroutines.flow.update import kotlinx.coroutines.flow.update
import li.songe.gkd.BuildConfig import li.songe.gkd.META
import li.songe.gkd.MainActivity import li.songe.gkd.MainActivity
import li.songe.gkd.ui.component.RotatingLoadingIcon import li.songe.gkd.ui.component.RotatingLoadingIcon
import li.songe.gkd.ui.component.SettingItem import li.songe.gkd.ui.component.SettingItem
@ -297,7 +297,7 @@ fun useSettingsPage(): ScaffoldExt {
}) })
} }
if (BuildConfig.ENABLED_UPDATE) { if (META.updateEnabled) {
Text( Text(
text = "更新", text = "更新",
modifier = Modifier.titleItemPadding(), modifier = Modifier.titleItemPadding(),

View File

@ -1,7 +1,6 @@
package li.songe.gkd.util package li.songe.gkd.util
import android.webkit.URLUtil import android.webkit.URLUtil
import li.songe.gkd.BuildConfig
const val FILE_SHORT_URL = "https://f.gkd.li/" const val FILE_SHORT_URL = "https://f.gkd.li/"
const val IMPORT_SHORT_URL = "https://i.gkd.li/i/" 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" 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( private val safeRemoteBaseUrls = arrayOf(
"https://registry.npmmirror.com/@gkd-kit/", "https://registry.npmmirror.com/@gkd-kit/",
"https://raw.githubusercontent.com/gkd-kit/", "https://raw.githubusercontent.com/gkd-kit/",

View File

@ -9,7 +9,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import li.songe.gkd.BuildConfig import li.songe.gkd.META
import li.songe.gkd.appScope import li.songe.gkd.appScope
private inline fun <reified T> createStorageFlow( private inline fun <reified T> createStorageFlow(
@ -49,7 +49,7 @@ data class Store(
val httpServerPort: Int = 8888, val httpServerPort: Int = 8888,
val updateSubsInterval: Long = UpdateTimeOption.Everyday.value, val updateSubsInterval: Long = UpdateTimeOption.Everyday.value,
val captureVolumeChange: Boolean = false, val captureVolumeChange: Boolean = false,
val autoCheckAppUpdate: Boolean = BuildConfig.ENABLED_UPDATE, val autoCheckAppUpdate: Boolean = META.updateEnabled,
val toastWhenClick: Boolean = true, val toastWhenClick: Boolean = true,
val clickToast: String = "GKD", val clickToast: String = "GKD",
val autoClearMemorySubs: Boolean = true, val autoClearMemorySubs: Boolean = true,
@ -68,7 +68,7 @@ data class Store(
val useCustomNotifText: Boolean = false, val useCustomNotifText: Boolean = false,
val customNotifText: String = "\${i}全局/\${k}应用/\${u}规则组/\${n}触发", val customNotifText: String = "\${i}全局/\${k}应用/\${u}规则组/\${n}触发",
val enableActivityLog: Boolean = false, 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 { val storeFlow by lazy {

View File

@ -31,7 +31,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import li.songe.gkd.BuildConfig import li.songe.gkd.META
import li.songe.gkd.MainActivity import li.songe.gkd.MainActivity
import li.songe.gkd.MainViewModel import li.songe.gkd.MainViewModel
import li.songe.gkd.app import li.songe.gkd.app
@ -73,9 +73,9 @@ suspend fun UpdateStatus.checkUpdate(): NewVersion? {
checkUpdatingFlow.value = true checkUpdatingFlow.value = true
try { try {
val newVersion = client.get(UPDATE_URL).body<NewVersion>() val newVersion = client.get(UPDATE_URL).body<NewVersion>()
if (newVersion.versionCode > BuildConfig.VERSION_CODE) { if (newVersion.versionCode > META.versionCode) {
newVersionFlow.value = 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 return newVersion
} else { } else {
Log.d("Upgrade", "no new version") Log.d("Upgrade", "no new version")
@ -130,7 +130,7 @@ fun UpgradeDialog(status: UpdateStatus) {
AlertDialog(title = { AlertDialog(title = {
Text(text = "新版本") Text(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) { if (newVersionVal.versionLogs.size > 1) {
newVersionVal.versionLogs.joinToString("\n\n") { v -> "v${v.name}\n${v.desc}" } newVersionVal.versionLogs.joinToString("\n\n") { v -> "v${v.name}\n${v.desc}" }
} else if (newVersionVal.versionLogs.isNotEmpty()) { } else if (newVersionVal.versionLogs.isNotEmpty()) {

View File

@ -22,7 +22,6 @@ android {
} }
buildFeatures { buildFeatures {
aidl = true aidl = true
buildConfig = false
} }
} }