Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.

Commit 8df04f9

Browse files
committed
Fixed the bug that crashed the whole program if you clicked on an item, now need to fix the not updating right list
1 parent 4296454 commit 8df04f9

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

res/blacklisted.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["C:\\Program Files (x86)\\Steam\\steam.exe","C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminal_1.6.10571.0_x64__8wekyb3d8bbwe\\OpenConsole.exe","C:\\Program Files\\WindowsApps\\Microsoft.WindowsStore_12101.1001.14.0_x64__8wekyb3d8bbwe\\WinStore.App.exe","C:\\Program Files\\WindowsApps\\Microsoft.ZuneMusic_10.20122.11121.0_x64__8wekyb3d8bbwe\\Music.UI.exe","C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"]
1+
["C:\\Users\\Apoc\\AppData\\Local\\JetBrains\\IntelliJ IDEA 2020.3\\bin\\idea64.exe","C:\\Users\\Apoc\\AppData\\Local\\JetBrains\\IntelliJ IDEA 2020.3\\jbr\\bin\\jcef_helper.exe","C:\\Program Files\\WindowsApps\\Microsoft.WindowsStore_12101.1001.14.0_x64__8wekyb3d8bbwe\\WinStore.App.exe","C:\\Users\\Apoc\\scoop\\apps\\spotify-latest\\1.1.56.595.g2d2da0de\\Spotify.exe","C:\\Program Files\\WindowsApps\\Microsoft.ZuneMusic_10.20122.11121.0_x64__8wekyb3d8bbwe\\Music.UI.exe"]

src/main/kotlin/KotlinGUI.kt

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import androidx.compose.desktop.Window
22
import androidx.compose.foundation.*
33
import androidx.compose.foundation.layout.*
44
import androidx.compose.foundation.lazy.LazyColumn
5+
import androidx.compose.foundation.lazy.LazyItemScope
6+
import androidx.compose.foundation.lazy.LazyListScope
57
import androidx.compose.foundation.lazy.items
68
import androidx.compose.foundation.shape.RoundedCornerShape
79
import androidx.compose.material.*
8-
import androidx.compose.runtime.Composable
9-
import androidx.compose.runtime.mutableStateListOf
10-
import androidx.compose.runtime.mutableStateOf
11-
import androidx.compose.runtime.remember
10+
import androidx.compose.runtime.*
1211
import androidx.compose.runtime.snapshots.SnapshotStateList
1312
import androidx.compose.ui.Alignment
1413
import androidx.compose.ui.Modifier
@@ -19,7 +18,6 @@ import androidx.compose.ui.text.font.FontWeight
1918
import androidx.compose.ui.text.platform.Font
2019
import androidx.compose.ui.text.style.TextAlign
2120
import androidx.compose.ui.unit.IntSize
22-
import androidx.compose.ui.unit.TextUnit
2321
import androidx.compose.ui.unit.dp
2422
import io.PersistenceHelper
2523
import processes.Process
@@ -35,7 +33,6 @@ import javax.sound.sampled.Clip
3533
import javax.sound.sampled.FloatControl
3634
import kotlin.concurrent.fixedRateTimer
3735

38-
@ExperimentalFoundationApi
3936
class KotlinGUI {
4037
private val icon: BufferedImage = try {
4138
ImageIO.read(File(Path.of("res", "shield-alt-solid.png").toUri()))
@@ -94,11 +91,11 @@ class KotlinGUI {
9491
fun getWindow() {
9592
return Window(
9693
title = "APT",
97-
size = IntSize(1280,720),
94+
size = IntSize(800, 600),
9895
icon = icon,
9996
onDismissRequest = windowCloseRequest,
10097
) {
101-
val automaticallyKillDisallowed = remember { mutableStateOf(false) }
98+
val automaticallyKillDisallowed = mutableStateOf(false)
10299
val processList: SnapshotStateList<Process> = mutableStateListOf()
103100
processList.addAll(ProcessHandler.computeFilteredProcessList(true))
104101
daemonTimers.add(initializeProcessUpdateTimer(processList))
@@ -108,19 +105,29 @@ class KotlinGUI {
108105

109106
defaultTheme {
110107
Box(modifier = Modifier.background(MaterialTheme.colors.background).fillMaxSize()) {
111-
Row(modifier = Modifier.fillMaxWidth().fillMaxHeight(1f)) {
108+
Row(modifier = Modifier.fillMaxWidth().fillMaxHeight(0.8f)) {
112109
LazyColumn(
113110
Modifier.fillMaxWidth(0.5f),
114111
verticalArrangement = Arrangement.spacedBy(3.dp),
115112
horizontalAlignment = Alignment.CenterHorizontally,
116113
contentPadding = PaddingValues(10.dp),
117114
) {
118-
stickyHeader {
119-
defaultHeader("All Processes")
115+
item {
116+
Text(
117+
text = "All Processes",
118+
color = MaterialTheme.colors.secondary,
119+
style = MaterialTheme.typography.h4,
120+
fontWeight = FontWeight.Thin,
121+
textAlign = TextAlign.Center,
122+
modifier = Modifier.background(MaterialTheme.colors.surface),
123+
)
124+
120125
}
121-
items(processList) { proc ->
122-
textBox(proc) {
123-
ProcessHandler.blacklisted.add(proc.command())
126+
processList.forEach { proc ->
127+
item {
128+
textBox(proc) {
129+
ProcessHandler.blacklisted.add(proc.command())
130+
}
124131
}
125132
}
126133
}
@@ -130,8 +137,15 @@ class KotlinGUI {
130137
horizontalAlignment = Alignment.CenterHorizontally,
131138
contentPadding = PaddingValues(10.dp),
132139
) {
133-
stickyHeader {
134-
defaultHeader("Blacklisted Processes")
140+
item {
141+
Text(
142+
text = "Blacklisted Processes",
143+
color = MaterialTheme.colors.secondary,
144+
style = MaterialTheme.typography.h4,
145+
fontWeight = FontWeight.Thin,
146+
textAlign = TextAlign.Center,
147+
modifier = Modifier.background(MaterialTheme.colors.surface),
148+
)
135149
}
136150
item {
137151
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
@@ -153,25 +167,14 @@ class KotlinGUI {
153167
}
154168
}
155169
}
170+
156171
}
157172

158173
}
159174
}
160175
}
161176
}
162177

163-
@Composable
164-
private fun defaultHeader(text: String ) {
165-
Text(
166-
text = text,
167-
color = MaterialTheme.colors.secondary,
168-
style = MaterialTheme.typography.h4,
169-
fontWeight = FontWeight.Thin,
170-
textAlign = TextAlign.Center,
171-
modifier = Modifier.background(MaterialTheme.colors.surface),
172-
)
173-
}
174-
175178
private fun initializeProcessUpdateTimer(list: SnapshotStateList<Process>): Timer {
176179
return fixedRateTimer("Update", true, 1000L, 1000L) {
177180
val newList = ProcessHandler.computeFilteredProcessList(false)

0 commit comments

Comments
 (0)