Skip to content

Commit a801a75

Browse files
authored
Merge pull request #158 from hossain-khan/154-make-log-list-better
[UX/UX] Improve the log list
2 parents 2d2116e + 200779d commit a801a75

File tree

9 files changed

+242
-52
lines changed

9 files changed

+242
-52
lines changed

app/src/main/java/dev/hossain/remotenotify/db/AlertCheckLogDao.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dev.hossain.remotenotify.db
33
import androidx.room.Dao
44
import androidx.room.Insert
55
import androidx.room.Query
6+
import androidx.room.Transaction
67
import kotlinx.coroutines.flow.Flow
78

89
@Dao
@@ -57,4 +58,13 @@ interface AlertCheckLogDao {
5758
""",
5859
)
5960
fun getLatestCheckLog(): Flow<AlertCheckLogEntity?>
61+
62+
@Transaction
63+
@Query(
64+
"""
65+
SELECT * FROM alert_check_log
66+
ORDER BY checked_at DESC
67+
""",
68+
)
69+
fun getAllLogsWithConfig(): Flow<List<AlertLogWithConfig>>
6070
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dev.hossain.remotenotify.db
2+
3+
import androidx.room.Embedded
4+
import androidx.room.Relation
5+
6+
data class AlertLogWithConfig(
7+
@Embedded val log: AlertCheckLogEntity,
8+
@Relation(
9+
parentColumn = "alert_config_id",
10+
entityColumn = "id",
11+
)
12+
val config: AlertConfigEntity,
13+
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
11
package dev.hossain.remotenotify.model
22

33
import dev.hossain.remotenotify.db.AlertCheckLogEntity
4+
import dev.hossain.remotenotify.db.AlertLogWithConfig
5+
import dev.hossain.remotenotify.notifier.NotifierType
46

57
data class AlertCheckLog(
68
val checkedOn: Long,
79
val alertType: AlertType,
810
val isAlertSent: Boolean,
11+
val notifierType: NotifierType?,
912
val stateValue: Int,
13+
val configId: Long,
14+
val configBatteryPercentage: Int,
15+
val configStorageMinSpaceGb: Int,
16+
val configCreatedOn: Long,
1017
)
1118

1219
fun AlertCheckLogEntity.toAlertCheckLog(): AlertCheckLog =
1320
AlertCheckLog(
1421
checkedOn = checkedAt,
1522
alertType = alertType,
1623
isAlertSent = alertTriggered,
24+
notifierType = notifierType,
1725
stateValue = alertStateValue,
26+
configId = 0,
27+
configBatteryPercentage = 0,
28+
configStorageMinSpaceGb = 0,
29+
configCreatedOn = 0,
30+
)
31+
32+
fun AlertLogWithConfig.toAlertCheckLog(): AlertCheckLog =
33+
AlertCheckLog(
34+
checkedOn = log.checkedAt,
35+
alertType = log.alertType,
36+
isAlertSent = log.alertTriggered,
37+
notifierType = log.notifierType,
38+
stateValue = log.alertStateValue,
39+
configId = config.id,
40+
configBatteryPercentage = config.batteryPercentage,
41+
configStorageMinSpaceGb = config.storageMinSpaceGb,
42+
configCreatedOn = config.createdOn,
1843
)

app/src/main/java/dev/hossain/remotenotify/ui/addalert/AddNewRemoteAlert.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import androidx.compose.foundation.layout.Spacer
99
import androidx.compose.foundation.layout.fillMaxWidth
1010
import androidx.compose.foundation.layout.height
1111
import androidx.compose.foundation.layout.padding
12+
import androidx.compose.foundation.rememberScrollState
13+
import androidx.compose.foundation.verticalScroll
1214
import androidx.compose.material.icons.Icons
1315
import androidx.compose.material.icons.automirrored.filled.ArrowBack
1416
import androidx.compose.material3.Button
@@ -186,6 +188,7 @@ fun AddNewRemoteAlertUi(
186188
Modifier
187189
.padding(innerPadding)
188190
.padding(16.dp)
191+
.verticalScroll(rememberScrollState())
189192
.fillMaxWidth(),
190193
verticalArrangement = Arrangement.spacedBy(24.dp),
191194
) {

0 commit comments

Comments
 (0)