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 @@ -42,6 +42,7 @@ import compose.icons.TablerIcons
import compose.icons.tablericons.Copy
import compose.icons.tablericons.DotsVertical
import compose.icons.tablericons.Edit
import compose.icons.tablericons.Refresh
import compose.icons.tablericons.Trash
import java.text.DateFormat
import java.text.SimpleDateFormat
Expand All @@ -61,6 +62,7 @@ fun DeeprItem(
onEditClick: ((GetLinksAndTags) -> Unit)? = null,
onItemLongClick: ((GetLinksAndTags) -> Unit)? = null,
onTagClick: ((String) -> Unit)? = null,
onResetOpenedCountClick: ((GetLinksAndTags) -> Unit)? = null,
onDeleteClick: ((GetLinksAndTags) -> Unit)? = null,
) {
var expanded by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -173,6 +175,19 @@ fun DeeprItem(
)
},
)
DropdownMenuItem(
text = { Text(stringResource(R.string.reset_opened_count)) },
onClick = {
onResetOpenedCountClick?.invoke(account)
expanded = false
},
leadingIcon = {
Icon(
TablerIcons.Refresh,
contentDescription = stringResource(R.string.reset_opened_count),
)
},
)
DropdownMenuItem(
text = { Text(stringResource(R.string.delete)) },
onClick = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ fun Content(
viewModel.setSelectedTagByName(it)
}
},
onResetOpenedCountClick = {
viewModel.resetOpenedCount(it.id)
Toast.makeText(context, "Opened count reset", Toast.LENGTH_SHORT).show()
},
onDeleteClick = {
showDeleteConfirmDialog = it
},
Expand All @@ -476,6 +480,7 @@ fun DeeprList(
onItemLongClick: (GetLinksAndTags) -> Unit,
onQrCodeCLick: (GetLinksAndTags) -> Unit,
onTagClick: (String) -> Unit,
onResetOpenedCountClick: (GetLinksAndTags) -> Unit,
onDeleteClick: (GetLinksAndTags) -> Unit,
modifier: Modifier = Modifier,
) {
Expand Down Expand Up @@ -545,6 +550,7 @@ fun DeeprList(
onItemLongClick = onItemLongClick,
onQrCodeClick = onQrCodeCLick,
onTagClick = onTagClick,
onResetOpenedCountClick = onResetOpenedCountClick,
onDeleteClick = onDeleteClick,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ class AccountViewModel(
}
}

fun resetOpenedCount(id: Long) {
viewModelScope.launch(Dispatchers.IO) {
deeprQueries.resetOpenedCount(id)
}
}

fun updateDeeplink(
id: Long,
newLink: String,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<string name="delete_confirmation_title">Delete Link?</string>
<string name="delete_confirmation_message">Are you sure you want to delete this link?</string>
<string name="remove_tag">Remove tag</string>
<string name="reset_opened_count">Reset opened count</string>
<string name="failed_to_fetch_metadata">Failed to fetch metadata</string>
<string name="opened_count">Opened: %d</string>
<string name="tags_label">Tags:</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/sqldelight/com/yogeshpaliyal/deepr/Deepr.sq
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ DELETE FROM Deepr WHERE id = ?;
incrementOpenedCount:
UPDATE Deepr SET openedCount = openedCount + 1 WHERE id = ?;

resetOpenedCount:
UPDATE Deepr SET openedCount = 0 WHERE id = ?;

updateDeeplink:
UPDATE Deepr SET link = ? , name = ? WHERE id = ?;

Expand Down