You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
manager: show modules update count on status card only if any update is vailable
This commit is contained in:
@@ -35,6 +35,7 @@ import androidx.compose.ui.text.toUpperCase
|
|||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.content.pm.PackageInfoCompat
|
import androidx.core.content.pm.PackageInfoCompat
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.dergoogler.mmrl.ui.component.LabelItem
|
import com.dergoogler.mmrl.ui.component.LabelItem
|
||||||
import com.dergoogler.mmrl.ui.component.LabelItemDefaults
|
import com.dergoogler.mmrl.ui.component.LabelItemDefaults
|
||||||
import com.dergoogler.mmrl.ui.component.text.TextRow
|
import com.dergoogler.mmrl.ui.component.text.TextRow
|
||||||
@@ -49,6 +50,7 @@ import com.rifsxd.ksunext.R
|
|||||||
import com.rifsxd.ksunext.ui.component.rememberConfirmDialog
|
import com.rifsxd.ksunext.ui.component.rememberConfirmDialog
|
||||||
import com.rifsxd.ksunext.ui.util.*
|
import com.rifsxd.ksunext.ui.util.*
|
||||||
import com.rifsxd.ksunext.ui.util.module.LatestVersionInfo
|
import com.rifsxd.ksunext.ui.util.module.LatestVersionInfo
|
||||||
|
import com.rifsxd.ksunext.ui.viewmodel.ModuleViewModel
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@@ -86,7 +88,13 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
|||||||
if (it >= Natives.MINIMAL_SUPPORTED_KERNEL_LKM && kernelVersion.isGKI()) Natives.isLkmMode else null
|
if (it >= Natives.MINIMAL_SUPPORTED_KERNEL_LKM && kernelVersion.isGKI()) Natives.isLkmMode else null
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusCard(kernelVersion, ksuVersion, lkmMode) {
|
val moduleViewModel: ModuleViewModel = viewModel()
|
||||||
|
val moduleUpdateCount = moduleViewModel.moduleList.count {
|
||||||
|
// Only count modules when update available (updateUrl is not empty)
|
||||||
|
moduleViewModel.checkUpdate(it).first.isNotEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusCard(kernelVersion, ksuVersion, lkmMode, moduleUpdateCount) {
|
||||||
navigator.navigate(InstallScreenDestination)
|
navigator.navigate(InstallScreenDestination)
|
||||||
}
|
}
|
||||||
if (isManager && Natives.requireNewKernel()) {
|
if (isManager && Natives.requireNewKernel()) {
|
||||||
@@ -241,6 +249,7 @@ private fun StatusCard(
|
|||||||
kernelVersion: KernelVersion,
|
kernelVersion: KernelVersion,
|
||||||
ksuVersion: Int?,
|
ksuVersion: Int?,
|
||||||
lkmMode: Boolean?,
|
lkmMode: Boolean?,
|
||||||
|
moduleUpdateCount: Int = 0,
|
||||||
onClickInstall: () -> Unit = {}
|
onClickInstall: () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@@ -337,6 +346,14 @@ private fun StatusCard(
|
|||||||
style = MaterialTheme.typography.bodyMedium
|
style = MaterialTheme.typography.bodyMedium
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (moduleUpdateCount > 0) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.home_module_update_count, moduleUpdateCount),
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.primary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val suSFS = getSuSFS()
|
val suSFS = getSuSFS()
|
||||||
if (suSFS == "Supported") {
|
if (suSFS == "Supported") {
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<string name="home_working_version">Version: %d</string>
|
<string name="home_working_version">Version: %d</string>
|
||||||
<string name="home_superuser_count">Superusers: %d</string>
|
<string name="home_superuser_count">Superusers: %d</string>
|
||||||
<string name="home_module_count">Modules: %d</string>
|
<string name="home_module_count">Modules: %d</string>
|
||||||
|
<string name="home_module_update_count">Updates: %d</string>
|
||||||
<string name="home_failure">KernelSU Next v2 signature not found in kernel! [ !KSU_NEXT || != size/hash ]</string>
|
<string name="home_failure">KernelSU Next v2 signature not found in kernel! [ !KSU_NEXT || != size/hash ]</string>
|
||||||
<string name="home_failure_tip">Ask your kernel developer to integrate KernelSU Next!</string>
|
<string name="home_failure_tip">Ask your kernel developer to integrate KernelSU Next!</string>
|
||||||
<string name="home_kernel">Kernel version</string>
|
<string name="home_kernel">Kernel version</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user