Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use 'bookmark' symbol for 'saved messages', tweak forwarding #2587

Merged
merged 9 commits into from
Feb 7, 2025
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Improve "message menu": many options are now faster accessible (#2586)
- When forwarding to "Saved Messages", if possible, save the message including context (#2587)
- Copy scanned QR code text to clipboard (#2582)
- Improve "All media empty" and "Block contact" wordings (#2580)
- Unify buttons and icons (#2584)
Expand Down
24 changes: 7 additions & 17 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -957,16 +957,12 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
self.reloadData()
}

private func isMarkerOrInfo(_ message: DcMsg) -> Bool {
return message.id == DC_MSG_ID_MARKER1 || message.id == DC_MSG_ID_DAYMARKER || message.isInfo || message.type == DC_MSG_VIDEOCHAT_INVITATION
}

private func canReply(to message: DcMsg) -> Bool {
return !isMarkerOrInfo(message) && dcChat.canSend
return !message.isMarkerOrInfo && dcChat.canSend
}

private func canReplyPrivately(to message: DcMsg) -> Bool {
return !isMarkerOrInfo(message) && dcChat.isGroup && !message.isFromCurrentSender
return !message.isMarkerOrInfo && dcChat.isGroup && !message.isFromCurrentSender
}

/// Verifies if the last message cell is fully visible
Expand Down Expand Up @@ -1679,13 +1675,7 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {

private func toggleSave(at indexPath: IndexPath) {
let message = dcContext.getMessage(id: messageIds[indexPath.row])
if dcChat.isSelfTalk {
if message.originalMessageId != 0 {
dcContext.deleteMessage(msgId: message.id)
} else {
askToDeleteMessage(id: message.id)
}
} else if message.savedMessageId != 0 {
if message.savedMessageId != 0 {
dcContext.deleteMessage(msgId: message.savedMessageId)
} else {
dcContext.saveMessages(with: [messageIds[indexPath.row]])
Expand Down Expand Up @@ -1927,14 +1917,14 @@ extension ChatViewController {
UIAction.menuAction(localizationKey: "forward", systemImageName: "arrowshape.turn.up.forward", indexPath: indexPath, action: forward)
)

if !isMarkerOrInfo(message) { // info-messages out of context results in confusion, see https://github.com/deltachat/deltachat-ios/issues/2567
if dcChat.isSelfTalk || message.savedMessageId != 0 {
if !dcChat.isSelfTalk && message.canSave {
if message.savedMessageId != 0 {
children.append(
UIAction.menuAction(localizationKey: "unsave", systemImageName: "star.slash", indexPath: indexPath, action: toggleSave)
UIAction.menuAction(localizationKey: "unsave", systemImageName: "bookmark.slash", indexPath: indexPath, action: toggleSave)
)
} else {
children.append(
UIAction.menuAction(localizationKey: "save_desktop", systemImageName: "star", indexPath: indexPath, action: toggleSave)
UIAction.menuAction(localizationKey: "save_desktop", systemImageName: "bookmark", indexPath: indexPath, action: toggleSave)
)
}
}
Expand Down
20 changes: 15 additions & 5 deletions deltachat-ios/Chat/Views/StatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class StatusView: UIView {
private let padlockView: UIImageView
private let locationView: UIImageView
private let stateView: UIImageView
private let savedView: UIImageView

override init(frame: CGRect) {

Expand All @@ -21,8 +22,10 @@ public class StatusView: UIView {
locationView.translatesAutoresizingMaskIntoConstraints = false
stateView = UIImageView()
stateView.translatesAutoresizingMaskIntoConstraints = false
savedView = UIImageView()
savedView.translatesAutoresizingMaskIntoConstraints = false

contentStackView = UIStackView(arrangedSubviews: [dateLabel, padlockView, locationView, stateView])
contentStackView = UIStackView(arrangedSubviews: [savedView, padlockView, dateLabel, locationView, stateView])
contentStackView.alignment = .center
contentStackView.spacing = 0
contentStackView.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -54,6 +57,9 @@ public class StatusView: UIView {

stateView.widthAnchor.constraint(equalToConstant: 20),
stateView.heightAnchor.constraint(equalToConstant: 20),

savedView.widthAnchor.constraint(equalToConstant: 6),
savedView.heightAnchor.constraint(equalToConstant: 11),
]

NSLayoutConstraint.activate(constraints)
Expand All @@ -64,17 +70,14 @@ public class StatusView: UIView {
dateLabel.text = nil
padlockView.isHidden = true
locationView.isHidden = true
savedView.isHidden = true
stateView.isHidden = true
}

public func update(message: DcMsg, tintColor: UIColor) {
dateLabel.text = message.formattedSentDate()
dateLabel.textColor = tintColor

if message.savedMessageId != 0 || message.originalMessageId != 0 {
dateLabel.text = "★ " + (dateLabel.text ?? "")
}

if message.showPadlock() {
padlockView.image = UIImage(named: "ic_lock")?.maskWithColor(color: tintColor)
padlockView.isHidden = false
Expand All @@ -89,6 +92,13 @@ public class StatusView: UIView {
locationView.isHidden = true
}

if message.savedMessageId != 0 || message.originalMessageId != 0 {
savedView.image = UIImage(systemName: "bookmark.fill")?.maskWithColor(color: tintColor)
savedView.isHidden = false
} else {
savedView.isHidden = true
}

let state: Int
if message.downloadState == DC_DOWNLOAD_IN_PROGRESS {
state = Int(DC_DOWNLOAD_IN_PROGRESS)
Expand Down
4 changes: 0 additions & 4 deletions deltachat-ios/DC/DcContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,6 @@ public class DcContext {
dc_resend_msgs(contextPointer, msgIds.compactMap { UInt32($0) }, Int32(msgIds.count))
}

public func forwardMessage(with msgId: Int, to chat: Int) {
dc_forward_msgs(contextPointer, [UInt32(msgId)], 1, UInt32(chat))
}

public func forwardMessages(with msgIds: [Int], to chat: Int) {
dc_forward_msgs(contextPointer, msgIds.compactMap { UInt32($0) }, Int32(msgIds.count), UInt32(chat))
}
Expand Down
8 changes: 8 additions & 0 deletions deltachat-ios/DC/DcMsg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public class DcMsg {
return Int(dc_msg_get_from_id(messagePointer))
}

public var isMarkerOrInfo: Bool {
return id == DC_MSG_ID_MARKER1 || id == DC_MSG_ID_DAYMARKER || isInfo || type == DC_MSG_VIDEOCHAT_INVITATION
}

public var canSave: Bool {
return !isMarkerOrInfo // info-messages out of context are confusing, see #2567
}

public var originalMessageId: Int {
return Int(dc_msg_get_original_msg_id(messagePointer))
}
Expand Down
17 changes: 14 additions & 3 deletions deltachat-ios/Helper/RelayHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,20 @@ class RelayHelper {
return forwardIds != nil || forwardText != nil || forwardFileData != nil || forwardVCardData != nil
}

func forwardIdsAndFinishRelaying(to chat: Int) {
if let messageIds = self.forwardIds {
RelayHelper.dcContext?.forwardMessages(with: messageIds, to: chat)
func forwardIdsAndFinishRelaying(to chatId: Int) {
if let messageIds = self.forwardIds, let dcContext = RelayHelper.dcContext {
if dcContext.getChat(chatId: chatId).isSelfTalk {
for id in messageIds {
let curr = dcContext.getMessage(id: id)
if curr.canSave && curr.savedMessageId == 0 && curr.chatId != chatId {
dcContext.saveMessages(with: [curr.id])
} else {
dcContext.forwardMessages(with: [curr.id], to: chatId)
}
}
} else {
dcContext.forwardMessages(with: messageIds, to: chatId)
}
}
finishRelaying()
}
Expand Down
Loading