123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- // _____ _
- // |_ _| |_ _ _ ___ ___ _ __ __ _
- // | | | ' \| '_/ -_) -_) ' \/ _` |_
- // |_| |_||_|_| \___\___|_|_|_\__,_(_)
- //
- // Threema iOS Client
- // Copyright (c) 2016-2020 Threema GmbH
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU Affero General Public License, version 3,
- // as published by the Free Software Foundation.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU Affero General Public License for more details.
- //
- // You should have received a copy of the GNU Affero General Public License
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
- #import "BaseMessage+Accessibility.h"
- #import "Conversation.h"
- #import "Contact.h"
- #import "BundleUtil.h"
- #import "ThreemaFramework/ThreemaFramework-swift.h"
- @implementation BaseMessage (AccessibilityUtil)
- - (NSString *)accessibilityMessageSender {
- NSString *senderText;
- if (self.isOwn.boolValue) {
- senderText = [BundleUtil localizedStringForKey:@"me"];
- } else if ([self.conversation isGroup]) {
- if (self.sender != nil) {
- senderText = self.sender.displayName;
- }
- } else {
- senderText = self.conversation.displayName;
- }
-
- return senderText;
- }
- - (NSString *)accessibilityMessageShortStatus {
- NSString *status = @"";
-
- if ([self.conversation isGroup]) {
- return status;
- }
-
- switch (self.messageState) {
- case MESSAGE_STATE_USER_ACK:
- status = [BundleUtil localizedStringForKey:@"status_acknowledged"];
- break;
-
- case MESSAGE_STATE_USER_DECLINED:
- status = [BundleUtil localizedStringForKey:@"status_declined"];
- break;
-
- case MESSAGE_STATE_FAILED:
- status = [BundleUtil localizedStringForKey:@"status_failed"];
- break;
-
- case MESSAGE_STATE_READ:
- status = [BundleUtil localizedStringForKey:@"status_read"];
- break;
-
- case MESSAGE_STATE_SENT:
- status = [BundleUtil localizedStringForKey:@"status_sent"];
- break;
-
- case MESSAGE_STATE_SENDING:
- status = [BundleUtil localizedStringForKey:@"status_sending"];
- break;
-
- case MESSAGE_STATE_DELIVERED:
- status = [BundleUtil localizedStringForKey:@"status_delivered"];
- break;
-
- default:
- break;
- }
-
- return status;
- }
- - (NSString *)accessibilityMessageStatus {
- NSString *status = @"";
-
- if ([self.conversation isGroup]) {
- return status;
- }
-
- switch (self.messageState) {
- case MESSAGE_STATE_SENDING:
- status = [BundleUtil localizedStringForKey:@"status_sending"];
- break;
-
- case MESSAGE_STATE_SENT:
- status = [BundleUtil localizedStringForKey:@"status_sent"];
- break;
-
- case MESSAGE_STATE_DELIVERED:
- status = [BundleUtil localizedStringForKey:@"status_delivered"];
- break;
-
- case MESSAGE_STATE_READ:
- status = [BundleUtil localizedStringForKey:@"status_read"];
- break;
-
- case MESSAGE_STATE_USER_ACK:
- status = [BundleUtil localizedStringForKey:@"status_acknowledged"];
- break;
-
- case MESSAGE_STATE_USER_DECLINED:
- status = [BundleUtil localizedStringForKey:@"status_declined"];
- break;
-
- case MESSAGE_STATE_FAILED:
- status = [BundleUtil localizedStringForKey:@"status_failed"];
- break;
-
- default:
- break;
- }
-
- return status;
- }
- - (NSString *)accessibilityMessageDate {
- NSDate *date = [self dateForCurrentState];
- if (date != nil) {
- return [DateFormatter accessibilityRelativeDayTime:date];
- }
-
- return nil;
- }
- @end
|