mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Clear active clipboard on removal, disallow removing pinned clipboard item without unpinning
This commit is contained in:
parent
87e44075e7
commit
1ae29aa9f1
@ -131,11 +131,15 @@ fun ClipboardEntryView(modifier: Modifier, clipboardEntry: ClipboardEntry, onPas
|
|||||||
|
|
||||||
IconButton(onClick = {
|
IconButton(onClick = {
|
||||||
onRemove(clipboardEntry)
|
onRemove(clipboardEntry)
|
||||||
}, modifier = Modifier.size(32.dp)) {
|
}, modifier = Modifier.size(32.dp), enabled = !clipboardEntry.pinned) {
|
||||||
Icon(
|
Icon(
|
||||||
painterResource(id = R.drawable.close),
|
painterResource(id = R.drawable.close),
|
||||||
contentDescription = "Close",
|
contentDescription = "Close",
|
||||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
tint = if(clipboardEntry.pinned) {
|
||||||
|
MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.2f)
|
||||||
|
} else {
|
||||||
|
MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
},
|
||||||
modifier = Modifier.size(16.dp)
|
modifier = Modifier.size(16.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -319,6 +323,13 @@ class ClipboardHistoryManager(val context: Context, val coroutineScope: Lifecycl
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onRemove(item: ClipboardEntry) {
|
fun onRemove(item: ClipboardEntry) {
|
||||||
|
// Clear the clipboard if the item being removed is the current one
|
||||||
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
// TODO: URI
|
||||||
|
if(item.text != null && item.text == clipboardManager.primaryClip?.getItemAt(0)?.coerceToText(context)) {
|
||||||
|
clipboardManager.clearPrimaryClip()
|
||||||
|
}
|
||||||
|
}
|
||||||
clipboardHistory.remove(item)
|
clipboardHistory.remove(item)
|
||||||
saveClipboard()
|
saveClipboard()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user