Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
<path android:fillColor="#FFFFFF" android:pathData="M261,933Q230,933 203.5,906.5Q177,880 177,849L177,229Q177,198 203.5,171.5Q230,145 261,145L440,145L440,80L520,80L520,145L699,145Q730,145 756.5,171.5Q783,198 783,229L783,849Q783,880 756.5,906.5Q730,933 699,933L261,933ZM380,773L440,773L440,305L380,305L380,773ZM520,773L580,773L580,305L520,305L520,773Z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

class LogDatabaseImpl @OptIn(DelicateCoroutinesApi::class) constructor(
private val dao: LogDao,
Expand Down Expand Up @@ -69,4 +70,10 @@ class LogDatabaseImpl @OptIn(DelicateCoroutinesApi::class) constructor(
it.map { it.toEntity() }
}
}

override suspend fun deleteAll() {
withContext(ioDispatcher) {
dao.deleteAll()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ interface LogDao {

@Query("SELECT * FROM Log JOIN log_fts ON log.id = log_fts.rowid WHERE log_fts MATCH :query AND log_level >= :logLevel ORDER BY date DESC")
fun filter(query: String, logLevel: Int = LogLevel.VERBOSE.priority): Flow<List<LogTable>>

@Query("DELETE FROM Log")
suspend fun deleteAll()
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class LogRepository(
return logDatabase.filter(filter)
}

suspend fun deleteAll() {
logDatabase.deleteAll()
}

companion object{
private var instance: LogRepository? = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ interface LogDatabase {
fun filter(logLevel: LogLevel): Flow<List<LogEntity>>

fun filter(filterEntity: FilterEntity): Flow<List<LogEntity>>
suspend fun deleteAll()
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ fun LogContent(state: LogState,
null
)
}
IconButton(onClick = {
event(LogEvent.DeleteAllLogsEvent)
}) {
Icon(
painter = painterResource(Res.drawable.outline_delete_24),
contentDescription = "Delete all logs"
)
}
})
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ sealed interface LogEvent {
object ScrollTopEvent: LogEvent
object PlayStopEvent: LogEvent
data class CardClickEvent(val id: Long): LogEvent
object DeleteAllLogsEvent: LogEvent
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class LogViewModel(
_state.update { it.copy(isPlaying = !it.isPlaying) }
}

is LogEvent.DeleteAllLogsEvent -> {
viewModelScope.launch {
logRepository.deleteAll()
}
}

else -> {}
}
}
Expand Down