From 4b0a88d6c9ad82315f3e6c6a2216a7cc2be25b3a Mon Sep 17 00:00:00 2001 From: Denis Morozov Date: Wed, 23 Aug 2017 12:53:32 +0300 Subject: [PATCH 1/2] Add new option to notification settings --- Riot/Assets/en.lproj/Vector.strings | 1 + Riot/ViewController/SettingsViewController.m | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 6c73d198d..33f2aece5 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -327,6 +327,7 @@ "settings_fail_to_update_profile" = "Fail to update profile"; "settings_enable_push_notif" = "Notifications on this device"; +"settings_show_decrypted_content" = "Show decrypted content"; "settings_global_settings_info" = "Global notification settings are available on your %@ web client"; "settings_pin_rooms_with_missed_notif" = "Pin rooms with missed notifications"; "settings_pin_rooms_with_unread" = "Pin rooms with unread messages"; diff --git a/Riot/ViewController/SettingsViewController.m b/Riot/ViewController/SettingsViewController.m index dfc8ad67d..5d66e5882 100644 --- a/Riot/ViewController/SettingsViewController.m +++ b/Riot/ViewController/SettingsViewController.m @@ -62,6 +62,7 @@ enum enum { NOTIFICATION_SETTINGS_ENABLE_PUSH_INDEX = 0, + NOTIFICATION_SETTINGS_SHOW_DECODED_CONTENT, NOTIFICATION_SETTINGS_GLOBAL_SETTINGS_INDEX, NOTIFICATION_SETTINGS_PIN_MISSED_NOTIFICATIONS_INDEX, NOTIFICATION_SETTINGS_PIN_UNREAD_INDEX, @@ -1613,6 +1614,18 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); cell = labelAndSwitchCell; } + else if (row == NOTIFICATION_SETTINGS_SHOW_DECODED_CONTENT) + { + MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; + + labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_show_decrypted_content", @"Vector", nil); + labelAndSwitchCell.mxkSwitch.on = account.showDecryptedContentInNotifications; + labelAndSwitchCell.mxkSwitch.enabled = account.pushNotificationServiceIsActive; + [labelAndSwitchCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventValueChanged]; + [labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleShowDecodedContent:) forControlEvents:UIControlEventValueChanged]; + + cell = labelAndSwitchCell; + } else if (row == NOTIFICATION_SETTINGS_GLOBAL_SETTINGS_INDEX) { MXKTableViewCell *globalInfoCell = [self getDefaultTableViewCell:tableView]; @@ -2601,6 +2614,12 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); } } +- (void)toggleShowDecodedContent:(id)sender +{ + MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; + account.showDecryptedContentInNotifications = !account.showDecryptedContentInNotifications; +} + - (void)toggleLocalContactsSync:(id)sender { UISwitch *switchButton = (UISwitch*)sender; From 6cff918820e4b3aff5f3bdcd01024ff926f018e3 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 25 Aug 2017 13:36:25 +0300 Subject: [PATCH 2/2] Change control event value --- Riot/ViewController/SettingsViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Riot/ViewController/SettingsViewController.m b/Riot/ViewController/SettingsViewController.m index 5d66e5882..7ec1ad9b3 100644 --- a/Riot/ViewController/SettingsViewController.m +++ b/Riot/ViewController/SettingsViewController.m @@ -1621,8 +1621,8 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_show_decrypted_content", @"Vector", nil); labelAndSwitchCell.mxkSwitch.on = account.showDecryptedContentInNotifications; labelAndSwitchCell.mxkSwitch.enabled = account.pushNotificationServiceIsActive; - [labelAndSwitchCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventValueChanged]; - [labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleShowDecodedContent:) forControlEvents:UIControlEventValueChanged]; + [labelAndSwitchCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; + [labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleShowDecodedContent:) forControlEvents:UIControlEventTouchUpInside]; cell = labelAndSwitchCell; }