Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from gkd-kit:main #30

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ local.properties
*.keystore

/_assets
/.kotlin
32 changes: 19 additions & 13 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.google.ksp)
alias(libs.plugins.google.hilt)
alias(libs.plugins.rikka.refine)
Expand Down Expand Up @@ -132,9 +133,6 @@ android {
compose = true
aidl = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
packagingOptions.resources.excludes += setOf(
// https://github.com/Kotlin/kotlinx.coroutines/issues/2023
"META-INF/**", "**/attach_hotspot_windows.dll",
Expand All @@ -146,21 +144,29 @@ android {
"**/custom.config.conf",
"**/custom.config.yaml",
)
configurations.configureEach {
// https://github.com/Kotlin/kotlinx.coroutines/issues/2023
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-debug")
}

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("room.incremental", "true")
arg("room.generateKotlin", "true")
}
sourceSets.configureEach {
kotlin.srcDir("${layout.buildDirectory.asFile.get()}/generated/ksp/$name/kotlin/")
}
}

configurations.configureEach {
// https://github.com/Kotlin/kotlinx.coroutines/issues/2023
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-debug")
}

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("room.incremental", "true")
arg("room.generateKotlin", "true")
}

composeCompiler {
// https://developer.android.com/develop/ui/compose/performance/stability/strongskipping?hl=zh-cn
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}

dependencies {

implementation(project(mapOf("path" to ":selector")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import kotlinx.coroutines.flow.updateAndGet
import li.songe.gkd.app
import li.songe.gkd.appScope
import li.songe.gkd.shizuku.shizukuIsSafeOK
import li.songe.gkd.util.appInfoCacheFlow
import li.songe.gkd.util.initOrResetAppInfoCache
import li.songe.gkd.util.launchTry

Expand Down Expand Up @@ -133,10 +132,7 @@ fun updatePermissionState() {
shizukuOkState
).forEach { it.updateAndGet() }

if (canQueryPkgState.stateFlow.value != canQueryPkgState.updateAndGet() ||
// https://github.com/gkd-kit/gkd/issues/543
appInfoCacheFlow.value.count { e -> !e.value.isSystem && !e.value.hidden } < 16
) {
if (canQueryPkgState.stateFlow.value != canQueryPkgState.updateAndGet()) {
appScope.launchTry {
initOrResetAppInfoCache()
}
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/kotlin/li/songe/gkd/ui/home/AppListPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Sort
import androidx.compose.material.icons.filled.Android
import androidx.compose.material.icons.filled.Apps
import androidx.compose.material.icons.filled.AppsOutage
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.PriorityHigh
import androidx.compose.material.icons.filled.Search
Expand Down Expand Up @@ -79,6 +80,7 @@ import li.songe.gkd.util.storeFlow
val appListNav = BottomNavItem(
label = "应用", icon = Icons.Default.Apps
)
val appListOutageNav = appListNav.copy(icon = Icons.Default.AppsOutage)

@Composable
fun useAppListPage(): ScaffoldExt {
Expand Down Expand Up @@ -124,7 +126,14 @@ fun useAppListPage(): ScaffoldExt {
}
})
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
return ScaffoldExt(navItem = appListNav,
val canQueryPkg by canQueryPkgState.stateFlow.collectAsState()
val navItem = if (canQueryPkg) {
appListNav
} else {
appListOutageNav
}
return ScaffoldExt(
navItem = navItem,
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
DisposableEffect(null) {
Expand Down Expand Up @@ -169,7 +178,6 @@ fun useAppListPage(): ScaffoldExt {
)
}
} else {
val canQueryPkg by canQueryPkgState.stateFlow.collectAsState()
if (!canQueryPkg) {
IconButton(onClick = vm.viewModelScope.launchAsFn {
checkOrRequestPermission(context, canQueryPkgState)
Expand Down
36 changes: 9 additions & 27 deletions app/src/main/kotlin/li/songe/gkd/ui/home/ControlPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.material.icons.automirrored.outlined.OpenInNew
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
import androidx.compose.material.icons.outlined.Home
import androidx.compose.material3.HorizontalDivider
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
Expand Down Expand Up @@ -75,6 +76,13 @@ fun useControlPage(): ScaffoldExt {
Text(
text = controlNav.label,
)
}, actions = {
IconButton(onClick = { context.openUri(HOME_PAGE_URL) }) {
Icon(
imageVector = Icons.AutoMirrored.Outlined.HelpOutline,
contentDescription = null,
)
}
})
}
) { padding ->
Expand Down Expand Up @@ -125,32 +133,6 @@ fun useControlPage(): ScaffoldExt {
}
})

Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clickable {
context.openUri(HOME_PAGE_URL)
}
.itemPadding(),
) {
Column(modifier = Modifier.weight(1f)) {
Text(
text = "使用说明",
style = MaterialTheme.typography.bodyLarge,
)
Text(
text = HOME_PAGE_URL,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.primary,
)
}
Icon(
imageVector = Icons.AutoMirrored.Outlined.OpenInNew,
contentDescription = null
)
}

val clickLogCount by vm.clickLogCountFlow.collectAsState()
Row(
horizontalArrangement = Arrangement.SpaceBetween,
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ plugins {

alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false

alias(libs.plugins.rikka.refine) apply false
}
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[versions]
kotlin = "1.9.23"
ksp = "1.9.23-1.0.19"
kotlin = "2.0.0"
ksp = "2.0.0-1.0.21"
compileSdk = "34"
targetSdk = "34"
buildToolsVersion = "34.0.0"
minSdk = "26"
android = "8.4.0"
android = "8.4.1"
compose = "1.6.7"
composeCompiler = "1.5.13"
rikka = "4.4.0"
room = "2.6.1"
paging = "3.3.0"
Expand Down Expand Up @@ -80,6 +79,7 @@ kotlin_serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
kotlin_parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
kotlin_multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin_compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
rikka_refine = { id = "dev.rikka.tools.refine", version.ref = "rikka" }
google_ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
google_hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
1 change: 1 addition & 0 deletions stability_config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
li.songe.gkd.*