Add presence offline mode setting

This commit is contained in:
aringenbach
2022-04-06 15:00:56 +02:00
parent 2f82ae129d
commit 320fa8d59a
8 changed files with 106 additions and 3 deletions
@@ -62,6 +62,7 @@ typedef NS_ENUM(NSUInteger, SECTION_TAG)
SECTION_TAG_IGNORED_USERS,
SECTION_TAG_INTEGRATIONS,
SECTION_TAG_USER_INTERFACE,
SECTION_TAG_PRESENCE,
SECTION_TAG_ADVANCED,
SECTION_TAG_ABOUT,
SECTION_TAG_LABS,
@@ -137,6 +138,11 @@ typedef NS_ENUM(NSUInteger, IDENTITY_SERVER)
IDENTITY_SERVER_INDEX
};
typedef NS_ENUM(NSUInteger, PRESENCE)
{
PRESENCE_OFFLINE_MODE = 0,
};
typedef NS_ENUM(NSUInteger, ADVANCED)
{
ADVANCED_SHOW_NSFW_ROOMS_INDEX = 0,
@@ -520,6 +526,16 @@ TableViewSectionsDelegate>
[tmpSections addObject: sectionUserInterface];
if(BuildSettings.presenceSettingsAllowConfiguration)
{
Section *sectionPresence = [Section sectionWithTag:SECTION_TAG_PRESENCE];
[sectionPresence addRowWithTag:PRESENCE_OFFLINE_MODE];
sectionPresence.headerTitle = VectorL10n.settingsPresence;
sectionPresence.footerTitle = VectorL10n.settingsPresenceOfflineModeDescription;
[tmpSections addObject:sectionPresence];
}
Section *sectionAdvanced = [Section sectionWithTag:SECTION_TAG_ADVANCED];
sectionAdvanced.headerTitle = [VectorL10n settingsAdvanced];
@@ -2287,6 +2303,24 @@ TableViewSectionsDelegate>
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
}
}
else if (section == SECTION_TAG_PRESENCE)
{
if (row == PRESENCE_OFFLINE_MODE)
{
MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
labelAndSwitchCell.mxkLabel.text = VectorL10n.settingsPresenceOfflineMode;
MXKAccount *account = MXKAccountManager.sharedManager.accounts.firstObject;
labelAndSwitchCell.mxkSwitch.on = account.preferredSyncPresence == MXPresenceOffline;
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
labelAndSwitchCell.mxkSwitch.enabled = YES;
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(togglePresenceOfflineMode:) forControlEvents:UIControlEventTouchUpInside];
cell = labelAndSwitchCell;
}
}
else if (section == SECTION_TAG_ADVANCED)
{
if (row == ADVANCED_SHOW_NSFW_ROOMS_INDEX)
@@ -3907,6 +3941,19 @@ TableViewSectionsDelegate>
self.deactivateAccountViewController = deactivateAccountViewController;
}
- (void)togglePresenceOfflineMode:(UISwitch *)sender
{
MXKAccount *account = MXKAccountManager.sharedManager.accounts.firstObject;
if (sender.isOn)
{
account.preferredSyncPresence = MXPresenceOffline;
}
else
{
account.preferredSyncPresence = MXPresenceOnline;
}
}
- (void)toggleNSFWPublicRoomsFiltering:(UISwitch *)sender
{
RiotSettings.shared.showNSFWPublicRooms = sender.isOn;