Optionally show UD status in message details

This commit is contained in:
Michael Kirk 2018-10-10 17:17:42 -06:00
parent 221ce513f1
commit 1544f8db46
6 changed files with 73 additions and 12 deletions

View File

@ -205,21 +205,33 @@ NS_ASSUME_NONNULL_BEGIN
}]];
[contents addSection:historyLogsSection];
OWSTableSection *unidentifiedDeliverySection = [OWSTableSection new];
unidentifiedDeliverySection.headerTitle
OWSTableSection *unidentifiedDeliveryIndicatorsSection = [OWSTableSection new];
unidentifiedDeliveryIndicatorsSection.headerTitle
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SECTION_TITLE", @"table section label");
unidentifiedDeliverySection.footerTitle
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SECTION_FOOTER", @"table section footer");
unidentifiedDeliveryIndicatorsSection.footerTitle
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS_FOOTER", @"table section footer");
OWSTableItem *showUDIndicatorsItem = [OWSTableItem
switchItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS", @"switch label")
isOn:weakSelf.preferences.shouldShowUnidentifiedDeliveryIndicators
target:weakSelf
selector:@selector(didToggleUDShowIndicatorsSwitch:)];
[unidentifiedDeliveryIndicatorsSection addItem:showUDIndicatorsItem];
OWSTableSection *unidentifiedDeliveryUnrestrictedSection = [OWSTableSection new];
OWSTableItem *unrestrictedAccessItem = [OWSTableItem
switchItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS", @"switch label")
isOn:weakSelf.udManager.shouldAllowUnrestrictedAccessLocal
target:weakSelf
selector:@selector(didToggleUDUnrestrictedAccessSwitch:)];
[unidentifiedDeliverySection addItem:unrestrictedAccessItem];
[unidentifiedDeliveryUnrestrictedSection addItem:unrestrictedAccessItem];
[contents addSection:unidentifiedDeliverySection];
unidentifiedDeliveryUnrestrictedSection.footerTitle
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER", @"table section footer");
[contents addSection:unidentifiedDeliveryIndicatorsSection];
[contents addSection:unidentifiedDeliveryUnrestrictedSection];
self.contents = contents;
}
@ -316,6 +328,12 @@ NS_ASSUME_NONNULL_BEGIN
[self.udManager setShouldAllowUnrestrictedAccessLocal:sender.isOn];
}
- (void)didToggleUDShowIndicatorsSwitch:(UISwitch *)sender
{
OWSLogInfo(@"toggled to: %@", (sender.isOn ? @"ON" : @"OFF"));
[self.preferences setShouldShowUnidentifiedDeliveryIndicators:sender.isOn];
}
- (void)show2FASettings
{
OWSLogInfo(@"");

View File

@ -37,12 +37,20 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
var attachmentStream: TSAttachmentStream?
var messageBody: String?
lazy var shouldShowUD: Bool = {
return self.preferences.shouldShowUnidentifiedDeliveryIndicators()
}()
var conversationStyle: ConversationStyle
private var contactShareViewHelper: ContactShareViewHelper!
// MARK: Dependencies
var preferences: OWSPreferences {
return Environment.shared.preferences
}
var contactsManager: OWSContactsManager {
return Environment.shared.contactsManager
}
@ -259,7 +267,12 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
// context of a table view.
let cellView = ContactCellView()
// We use the "short" status message to avoid being redundant with the section title.
cellView.accessoryMessage = shortStatusMessage
if self.shouldShowUD, recipientState.wasSentByUD {
// TODO once design is complete, replace stand-in emoji
cellView.accessoryMessage = shortStatusMessage.rtlSafeAppend(" ").rtlSafeAppend("💌")
} else {
cellView.accessoryMessage = shortStatusMessage
}
cellView.configure(withRecipientId: recipientId, contactsManager: self.contactsManager)
let wrapper = UIView()
@ -285,9 +298,13 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
}
}
var sentText = DateUtil.formatPastTimestampRelativeToNow(message.timestamp)
if self.shouldShowUD, let incomingMessage = message as? TSIncomingMessage, incomingMessage.wasReceivedByUD {
sentText = sentText.rtlSafeAppend(" ").rtlSafeAppend("💌")
}
let sentRow = valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SENT_DATE_TIME",
comment: "Label for the 'sent date & time' field of the 'message metadata' view."),
value: DateUtil.formatPastTimestampRelativeToNow(message.timestamp))
value: sentText)
sentRow.isUserInteractionEnabled = true
sentRow.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(didLongPressSent)))
rows.append(sentRow)

View File

@ -2093,14 +2093,20 @@
/* Title for the 'two factor auth' section of the privacy settings. */
"SETTINGS_TWO_FACTOR_AUTH_TITLE" = "Registration Lock";
/* table section footer */
"SETTINGS_UNIDENTIFIED_DELIVERY_SECTION_FOOTER" = "Normally, only users you've shared your profile with can contact you without identifying themselves to the Signal service. Unrestricted Access means *anyone* will be able to contact you without identifying themselves to the Signal service.";
/* table section label */
"SETTINGS_UNIDENTIFIED_DELIVERY_SECTION_TITLE" = "Unidentified Delivery";
/* switch label */
"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS" = "Unrestricted Access";
"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS" = "Display Indicators";
/* table section footer */
"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS_FOOTER" = "Show a status icon when you select \"More Info\" on messages that were sent using unidentified delivery.";
/* switch label */
"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS" = "Allow from Anyone";
/* table section footer */
"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER" = "Enable unidentified delivery for incoming messages from non-contacts and people with whom you have not shared your profile.";
/* No comment provided by engineer. */
"SETTINGS_VERSION" = "Version";

View File

@ -10,6 +10,10 @@ public extension String {
return self.trimmingCharacters(in: .whitespacesAndNewlines)
}
func rtlSafeAppend(_ string: String) -> String {
return (self as NSString).rtlSafeAppend(string)
}
// Truncates string to be less than or equal to byteCount, while ensuring we never truncate partial characters for multibyte characters.
func truncated(toByteCount byteCount: UInt) -> String? {
var lowerBoundCharCount = 0

View File

@ -58,6 +58,9 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification;
- (BOOL)hasGeneratedThumbnails;
- (void)setHasGeneratedThumbnails:(BOOL)value;
- (BOOL)shouldShowUnidentifiedDeliveryIndicators;
- (void)setShouldShowUnidentifiedDeliveryIndicators:(BOOL)value;
#pragma mark Callkit
- (BOOL)isSystemCallLogEnabled;

View File

@ -27,6 +27,8 @@ NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled
NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress";
NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView";
NSString *const OWSPreferencesKeyHasGeneratedThumbnails = @"OWSPreferencesKeyHasGeneratedThumbnails";
NSString *const OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators
= @"OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators";
NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySystemCallLogEnabled";
@ -188,6 +190,17 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
return [self tryGetValueForKey:OWSPreferencesKeyIOSUpgradeNagDate];
}
- (BOOL)shouldShowUnidentifiedDeliveryIndicators
{
NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators];
return preference ? [preference boolValue] : NO;
}
- (void)setShouldShowUnidentifiedDeliveryIndicators:(BOOL)value
{
[self setValueForKey:OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators toValue:@(value)];
}
#pragma mark - Calling
#pragma mark CallKit