MESSENGER-4016 add netiquette

This commit is contained in:
JanNiklas Grabowski
2023-01-23 14:42:33 +00:00
parent dc2c51706a
commit 4882c4ac49
5 changed files with 87 additions and 6 deletions
+66 -5
View File
@@ -215,6 +215,7 @@ typedef NS_ENUM(NSUInteger, ABOUT)
ABOUT_MARK_ALL_AS_READ_INDEX,
ABOUT_CLEAR_CACHE_INDEX,
ABOUT_REPORT_BUG_INDEX,
ABOUT_NETIQUETTE_INDEX
};
typedef NS_ENUM(NSUInteger, LABS_ENABLE)
@@ -686,6 +687,11 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
}
Section *sectionAbout = [Section sectionWithTag:SECTION_TAG_ABOUT];
// bwi: add netiquette if feature is enabled and available
if ([self isNetiquetteSettingsShown])
{
[sectionAbout addRowWithTag:ABOUT_NETIQUETTE_INDEX];
}
[sectionAbout addRowWithTag:ABOUT_VERSION_INDEX];
[sectionAbout addRowWithTag:ABOUT_OLM_VERSION_INDEX];
@@ -2772,10 +2778,18 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
cell = reportBugBtnCell;
}
}
else if (section == SECTION_TAG_ABOUT)
{
if (row == ABOUT_TERM_CONDITIONS_INDEX)
// bwi: show netiquette cell in about section
else if (row == ABOUT_NETIQUETTE_INDEX)
{
MXKTableViewCell *netiquetteCell = [self getDefaultTableViewCell:tableView];
netiquetteCell.textLabel.text = BWIL10n.bwiSettingsNetiquette;
[netiquetteCell vc_setAccessoryDisclosureIndicatorWithCurrentTheme];
cell = netiquetteCell;
}
else if (row == ABOUT_TERM_CONDITIONS_INDEX)
{
MXKTableViewCell *termAndConditionCell = [self getDefaultTableViewCell:tableView];
@@ -3239,7 +3253,12 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
}
else if (section == SECTION_TAG_ABOUT)
{
if (row == ABOUT_COPYRIGHT_INDEX)
// bwi: show netiquette infos
if (row == ABOUT_NETIQUETTE_INDEX)
{
[self showNetiquetteInfos];
}
else if (row == ABOUT_COPYRIGHT_INDEX)
{
WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithURL:BWIBuildSettings.shared.applicationCopyrightUrlString];
@@ -4496,6 +4515,24 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
RiotSettings.shared.enableLiveLocationSharing = sender.isOn;
}
// bwi: show netiquette infos in webview
- (void)showNetiquetteInfos
{
// Get local HTML content in preferred language (default language is german, if preferred language is not available)
NSString* htmlFile;
if ([[self bwiGetPreferredLanguageCode] isEqual: @"en"]) {
htmlFile = [[NSBundle mainBundle] pathForResource:BWIBuildSettings.shared.netiquetteEnHTML ofType:@"html" inDirectory:nil];
} else {
htmlFile = [[NSBundle mainBundle] pathForResource:BWIBuildSettings.shared.netiquetteDeHTML ofType:@"html" inDirectory:nil];
}
WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithLocalHTMLFile:htmlFile];
webViewViewController.title = BWIL10n.bwiSettingsNetiquette;
[webViewViewController vc_setLargeTitleDisplayMode:UINavigationItemLargeTitleDisplayModeNever];
[self pushViewController:webViewViewController];
}
#pragma mark - TextField listener
- (IBAction)textFieldDidChange:(id)sender
@@ -5150,6 +5187,30 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
[self pushViewController:ignoredUsersViewController];
}
- (BOOL) isNetiquetteSettingsShown {
if ([BWIBuildSettings.shared bwiShowNetiquetteInfos]) {
if ([[self bwiGetPreferredLanguageCode] isEqual: @"en"]) {
if ([[NSBundle mainBundle] pathForResource:BWIBuildSettings.shared.netiquetteEnHTML ofType:@"html" inDirectory:nil] != nil) {
return true;
} else {
return false;
}
} else {
if ([[NSBundle mainBundle] pathForResource:BWIBuildSettings.shared.netiquetteDeHTML ofType:@"html" inDirectory:nil] != nil) {
return true;
} else {
return false;
}
}
} else {
return false;
}
}
- (NSString*) bwiGetPreferredLanguageCode {
return ([[NSLocale componentsFromLocaleIdentifier:[[NSLocale preferredLanguages] firstObject]] objectForKey:@"kCFLocaleLanguageCodeKey"]);
}
#pragma mark - ThreadsBetaCoordinatorBridgePresenterDelegate
- (void)threadsBetaCoordinatorBridgePresenterDelegateDidTapEnable:(ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter