Skip to content
Merged
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
Expand Up @@ -5,6 +5,7 @@ import com.example.notimanager.domain.utils.IntentHelper.retrieveIntent
import com.example.notimanager.domain.model.Notification

data class NotificationDto(
val id: Long,
val title: String,
val subText: String,
val content: String,
Expand All @@ -15,6 +16,7 @@ data class NotificationDto(
){
fun toDomain(): Notification {
return Notification(
id = this.id,
title = this.title,
subText = this.subText,
content = this.content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ class NotificationAppRepository(
): Int {
return appIconDao.removePriority(appName)
}
override suspend fun deleteNotificationApp(
appName: String
): Int{
return notificationDao.deleteNotificationByAppName(appName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ class NotificationDomainRepository(
.map { it.toDomain() }
.toList()
}

override suspend fun deleteNotification(id: Long): Int {
return notificationDao.deleteNotificationById(id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ class NotificationTitleRepository(
return notificationIconDao.removePriority(notificationId)
}

override suspend fun deleteByTitle(appName: String, title: String): Int {
return notificationDao.deleteNotificationByTitle(appName, title)
}

override suspend fun deleteBySubText(appName: String, subText: String): Int {
return notificationDao.deleteNotificationBySubText(appName, subText)
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.notimanager.data.source.local.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
Expand Down Expand Up @@ -77,7 +78,7 @@ interface NotificationDao {

@Query(
"""
SELECT n.title, n.subText, n.content, n.timestamp, nm.intentActive, nm.intentArray, ni.iconBytes
SELECT n.id, n.title, n.subText, n.content, n.timestamp, nm.intentActive, nm.intentArray, ni.iconBytes
FROM notification AS n
INNER JOIN notification_meta AS nm ON n.id = nm.notificationId
INNER JOIN notification_icon AS ni ON n.id = ni.notificationId
Expand All @@ -89,7 +90,7 @@ interface NotificationDao {

@Query(
"""
SELECT n.title, n.subText, n.content, n.timestamp, nm.intentActive, nm.intentArray, ni.iconBytes
SELECT n.id, n.title, n.subText, n.content, n.timestamp, nm.intentActive, nm.intentArray, ni.iconBytes
FROM notification AS n
INNER JOIN notification_meta AS nm ON n.id = nm.notificationId
INNER JOIN notification_icon AS ni ON n.id = ni.notificationId
Expand All @@ -98,4 +99,16 @@ interface NotificationDao {
"""
)
suspend fun getNotificationSubTextList(appName: String, subText: String): List<NotificationDto>

@Query("DELETE FROM Notification WHERE appName = :appName")
suspend fun deleteNotificationByAppName(appName: String): Int

@Query("DELETE FROM Notification WHERE appName = :appName AND title = :title")
suspend fun deleteNotificationByTitle(appName: String, title: String): Int

@Query("DELETE FROM Notification WHERE appName = :appName AND subText = :subText")
suspend fun deleteNotificationBySubText(appName: String, subText: String): Int

@Query("DELETE FROM Notification WHERE id = :id")
suspend fun deleteNotificationById(id: Long): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import android.graphics.Bitmap

data class Notification(
val id: Long,
val title: String,
val subText: String,
val content: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ interface NotificationAppRepositoryInterface {
suspend fun getNotificationAppPriorityList(): List<NotificationApp>
suspend fun setAppPriority(appName: String, newPriority: Int): Int
suspend fun removeAppPriority(appName: String): Int
suspend fun deleteNotificationApp(appName: String): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import com.example.notimanager.domain.model.Notification
interface NotificationDomainRepositoryInterface {
suspend fun getNotificationList(appName: String, title: String): List<Notification>
suspend fun getNotificationSubTextList(appName: String, subText: String): List<Notification>
suspend fun deleteNotification(id: Long): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ interface NotificationTitleRepositoryInterface {
suspend fun getNotificationTitlePriorityList(appName: String): List<NotificationTitle>
suspend fun setTitlePriority(notificationId: Long, newPriority: Int): Int
suspend fun removeTitlePriority(notificationId: Long): Int
suspend fun deleteByTitle(appName: String, title: String): Int
suspend fun deleteBySubText(appName: String, subText: String): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ class NotificationAppUseCase(
): Int {
return repository.removeAppPriority(appName)
}

suspend fun deleteNotificationApp(
appName: String,
): Int{
return repository.deleteNotificationApp(appName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,18 @@ class NotificationTitleUseCase(
): Int {
return repository.removeTitlePriority(notificationId)
}

suspend fun deleteByTitle(
appName: String,
title: String
): Int{
return repository.deleteByTitle(appName, title)
}

suspend fun deleteBySubText(
appName: String,
subText: String
): Int{
return repository.deleteBySubText(appName, subText)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ class NotificationUseCase(
suspend fun getNotificationSubTextList(appName: String, subText: String): List<Notification>{
return repository.getNotificationSubTextList(appName, subText)
}

suspend fun deleteNotification(id: Long): Int{
return repository.deleteNotification(id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,11 @@ class NotificationAppPriorityViewModel @Inject constructor(
onComplete()
}
}

fun deleteApp(appName: String) {
viewModelScope.launch {
notificationAppUseCase.deleteNotificationApp(appName)
loadNotificationAppPriority()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ class NotificationAppViewModel @Inject constructor(
onComplete()
}
}

fun deleteNotificationApp(appName: String) {
viewModelScope.launch {
notificationAppUseCase.deleteNotificationApp(appName)
loadNotificationApps()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ class NotificationSubTextViewModel @Inject constructor(
}
}
}

fun deleteNotification(id: Long){
viewModelScope.launch {
notificationUseCase.deleteNotification(id)
loadNotification()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,22 @@ class NotificationTitlePriorityViewModel @Inject constructor(
onComplete()
}
}

fun deleteByTitle(
title: String
){
viewModelScope.launch {
notificationTitleUseCase.deleteByTitle(appName, title)
loadNotificationTitles()
}
}

fun deleteBySubText(
subText: String
){
viewModelScope.launch {
notificationTitleUseCase.deleteBySubText(appName, subText)
loadNotificationTitles()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,26 @@ class NotificationTitleViewModel @Inject constructor(
onComplete()
}
}

fun deleteByTitle(
title: String,
onComplete: () -> Unit
){
viewModelScope.launch {
notificationTitleUseCase.deleteByTitle(appName, title)
loadNotificationTitles()
onComplete()
}
}

fun deleteBySubText(
subText: String,
onComplete: () -> Unit
){
viewModelScope.launch {
notificationTitleUseCase.deleteBySubText(appName, subText)
loadNotificationTitles()
onComplete()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ class NotificationViewModel @Inject constructor(
}
}
}

fun deleteNotification(id: Long){
viewModelScope.launch {
notificationUseCase.deleteNotification(id)
loadNotification()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ fun NotificationAppItemView(
showModal = false
})
}
ClickableTextView(text = "삭제", onClick = {})
ClickableTextView(text = "삭제", onClick = {
viewModel.deleteNotificationApp(notification.appName)
showModal = false
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import com.example.notimanager.presentation.stateholder.state.NotificationState


@Composable
fun NotificationListView(notificationState: NotificationState) {
fun NotificationListView(
notificationState: NotificationState,
onDelete: (Long) -> Unit

) {
val context = LocalContext.current
var currentNoti by remember { mutableStateOf(notificationState.notificationList) }

Expand All @@ -38,21 +42,26 @@ fun NotificationListView(notificationState: NotificationState) {
currentNoti = notificationState.notificationList
}
}

LazyColumn(
modifier = Modifier.fillMaxSize()
) {
items(currentNoti) { notification ->
NotificationItemView (notification = notification, onClick = {
if (notification.intent?.action != null) {
context.startActivity(notification.intent);
}
})
if (notification.intent?.action != null)
context.startActivity(notification.intent) },
onDelete = onDelete
)
}
}
}

@Composable
fun NotificationItemView(notification: Notification, onClick: () -> Unit) {
fun NotificationItemView(
notification: Notification,
onClick: () -> Unit,
onDelete: (Long) -> Unit
) {
var showModal by remember { mutableStateOf(false) }
Row(
modifier = Modifier
Expand Down Expand Up @@ -107,6 +116,7 @@ fun NotificationItemView(notification: Notification, onClick: () -> Unit) {
})

ClickableTextView(text = "삭제", onClick = {
onDelete(notification.id)
showModal = false
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ fun NotificationTitleItemView(
showModal = false
})
}
ClickableTextView(text = "삭제", onClick = {})
ClickableTextView(text = "삭제", onClick = {
if (notification.subText == "")
viewModel.deleteByTitle(notification.title) { priorityViewModel.loadNotificationTitles() }
else
viewModel.deleteBySubText(notification.subText) { priorityViewModel.loadNotificationTitles() }
showModal = false
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import com.example.notimanager.presentation.stateholder.state.NotificationState
import com.example.notimanager.presentation.stateholder.viewmodel.NotificationViewModel
Expand Down Expand Up @@ -59,7 +60,7 @@ fun NotificationScreen(navController: NavController, appName: String = "", title
modifier = Modifier.padding(innerPadding)
) {
val notificationState by viewModel.notificationState.observeAsState(NotificationState())
NotificationListView(notificationState)
NotificationListView(notificationState, viewModel::deleteNotification)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun NotificationSubScreen(navController: NavController, appName: String = "", su
modifier = Modifier.padding(innerPadding)
) {
val notificationState by viewModel.notificationState.observeAsState(NotificationState())
NotificationListView(notificationState)
NotificationListView(notificationState, viewModel::deleteNotification)
}
}
}
Loading