mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Delete messages from view by long clicking. Looking into clearing "all messages" & menu for deleting individual messages
This commit is contained in:
parent
c08c652d97
commit
e27a76633c
4 changed files with 20 additions and 18 deletions
|
|
@ -66,6 +66,9 @@ interface IMeshService {
|
|||
*/
|
||||
void send(inout DataPacket packet);
|
||||
|
||||
|
||||
void delete(int position);
|
||||
|
||||
/**
|
||||
Get the IDs of everyone on the mesh. You should also subscribe for NODE_CHANGE broadcasts.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class MessagesState(private val ui: UIViewModel) : Logging {
|
|||
debug("Removing message from view id=${m.id}")
|
||||
|
||||
messagesList.remove(m)
|
||||
messages.value = messagesList;
|
||||
messages.value = messagesList
|
||||
}
|
||||
|
||||
fun updateStatus(id: Int, status: MessageStatus) {
|
||||
|
|
@ -88,19 +88,18 @@ class MessagesState(private val ui: UIViewModel) : Logging {
|
|||
addMessage(p)
|
||||
}
|
||||
|
||||
fun deleteMessage(str: String, dest: String = DataPacket.ID_BROADCAST) {
|
||||
fun deleteMessage(packet: DataPacket, position: Int) {
|
||||
val service = ui.meshService
|
||||
val p = DataPacket(str, dest)
|
||||
|
||||
if (service != null) {
|
||||
try {
|
||||
service.send(p)
|
||||
service.delete(position)
|
||||
} catch (ex: RemoteException) {
|
||||
p.errorMessage = "Error: ${ex.message}"
|
||||
packet.errorMessage = "Error: ${ex.message}"
|
||||
}
|
||||
} else {
|
||||
p.errorMessage = "Error: No Mesh service"
|
||||
packet.errorMessage = "Error: No Mesh service"
|
||||
}
|
||||
removeMessage(p)
|
||||
removeMessage(packet)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1018,10 +1018,10 @@ class MeshService : Service(), Logging {
|
|||
else
|
||||
broadcastSecs * 1000L
|
||||
|
||||
if (prefs.locationShare == RadioConfigProtos.LocationSharing.LocDisabled) {
|
||||
info("GPS location sharing is disabled")
|
||||
desiredInterval = 0
|
||||
}
|
||||
if (prefs.locationShare == RadioConfigProtos.LocationSharing.LocDisabled) {
|
||||
info("GPS location sharing is disabled")
|
||||
desiredInterval = 0
|
||||
}
|
||||
|
||||
// if (prefs.fixedPosition) {
|
||||
// info("Node has fixed position, therefore not overriding position")
|
||||
|
|
@ -1783,6 +1783,12 @@ class MeshService : Service(), Logging {
|
|||
this@MeshService.setOwner(myId, longName, shortName)
|
||||
}
|
||||
|
||||
override fun delete(position: Int) {
|
||||
if (position >= 0) {
|
||||
recentDataPackets.removeAt(position)
|
||||
}
|
||||
}
|
||||
|
||||
override fun send(p: DataPacket) {
|
||||
toRemoteExceptions {
|
||||
// Init from and id
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
|
|||
val marginParams = holder.card.layoutParams as ViewGroup.MarginLayoutParams
|
||||
val messageOffset = resources.getDimensionPixelOffset(R.dimen.message_offset)
|
||||
holder.card.setOnLongClickListener {
|
||||
this.onLongCLick(position)
|
||||
model.messagesState.deleteMessage(messages[position], position)
|
||||
true
|
||||
}
|
||||
if (isMe) {
|
||||
|
|
@ -236,12 +236,6 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
|
|||
if (itemCount != 0)
|
||||
binding.messageListView.scrollToPosition(itemCount - 1)
|
||||
}
|
||||
|
||||
fun onLongCLick(position: Int) {
|
||||
messages = messages.filter { x -> x != messages[position] }.toTypedArray()
|
||||
onMessagesChanged(messages.toList())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue