Skip to content

Commit

Permalink
Merge pull request #5 from h4ckm310n/4-clear-logs
Browse files Browse the repository at this point in the history
Feat: Add a button to clear logs
  • Loading branch information
h4ckm310n authored Oct 1, 2023
2 parents f336cbd + 4673691 commit 9c366cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/com/h4ckm310n/s5w2c/Logger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ object Logger {
items.add(LogItem(2, content))
}
}

fun clearLogs() {
MainScope().launch(Dispatchers.Main) {
items.clear()
}
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/h4ckm310n/s5w2c/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class MainActivity : ComponentActivity() {
}) {
Text(text = if (enabled.value) "关闭" else "开启")
}
Spacer(modifier = Modifier.padding(10.dp))
Button(onClick = { Logger.clearLogs() }) {
Text(text = "清空日志")
}
}

Text(text = "运行日志")
Expand Down

0 comments on commit 9c366cf

Please sign in to comment.