mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-24 10:32:46 +02:00
Merge branch 'master' into callkit
# Conflicts: # Riot.xcodeproj/project.pbxproj # Riot/AppDelegate.m # Riot/ViewController/SettingsViewController.m
This commit is contained in:
@@ -39,7 +39,9 @@
|
||||
#import "RiotDesignValues.h"
|
||||
#import "TableViewCellWithPhoneNumberTextField.h"
|
||||
|
||||
static NSString* const kSettingsViewControllerPhoneBookCountryCellId = @"kSettingsViewControllerPhoneBookCountryCellId";
|
||||
#import "GBDeviceInfo_iOS.h"
|
||||
|
||||
NSString* const kSettingsViewControllerPhoneBookCountryCellId = @"kSettingsViewControllerPhoneBookCountryCellId";
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -97,6 +99,7 @@ enum
|
||||
OTHER_PRIVACY_INDEX,
|
||||
OTHER_THIRD_PARTY_INDEX,
|
||||
OTHER_CRASH_REPORT_INDEX,
|
||||
OTHER_ENABLE_RAGESHAKE_INDEX,
|
||||
OTHER_MARK_ALL_AS_READ_INDEX,
|
||||
OTHER_CLEAR_CACHE_INDEX,
|
||||
OTHER_REPORT_BUG_INDEX,
|
||||
@@ -106,9 +109,7 @@ enum
|
||||
enum
|
||||
{
|
||||
LABS_MATRIX_APPS_INDEX = 0,
|
||||
#ifdef USE_JITSI_WIDGET
|
||||
LABS_USE_JITSI_WIDGET_INDEX,
|
||||
#endif
|
||||
LABS_CRYPTO_INDEX,
|
||||
LABS_COUNT
|
||||
};
|
||||
@@ -212,9 +213,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
BOOL keepNewEmailEditing;
|
||||
BOOL keepNewPhoneNumberEditing;
|
||||
|
||||
// The user interface theme cell
|
||||
TableViewCellWithCheckBoxes *uiThemeCell;
|
||||
|
||||
// The current pushed view controller
|
||||
UIViewController *pushedViewController;
|
||||
}
|
||||
@@ -257,7 +255,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
[self.tableView registerClass:MXKTableViewCellWithLabelAndSwitch.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndSwitch defaultReuseIdentifier]];
|
||||
[self.tableView registerClass:MXKTableViewCellWithLabelAndMXKImageView.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndMXKImageView defaultReuseIdentifier]];
|
||||
[self.tableView registerClass:TableViewCellWithPhoneNumberTextField.class forCellReuseIdentifier:[TableViewCellWithPhoneNumberTextField defaultReuseIdentifier]];
|
||||
[self.tableView registerClass:TableViewCellWithCheckBoxes.class forCellReuseIdentifier:[TableViewCellWithCheckBoxes defaultReuseIdentifier]];
|
||||
|
||||
// Enable self sizing cells
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
||||
@@ -424,7 +421,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
// Observe kAppDelegateDidTapStatusBarNotificationObserver.
|
||||
kAppDelegateDidTapStatusBarNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kAppDelegateDidTapStatusBarNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
|
||||
|
||||
[self.tableView setContentOffset:CGPointMake(-self.tableView.contentInset.left, -self.tableView.contentInset.top) animated:YES];
|
||||
[self.tableView setContentOffset:CGPointMake(-self.tableView.mxk_adjustedContentInset.left, -self.tableView.mxk_adjustedContentInset.top) animated:YES];
|
||||
|
||||
}];
|
||||
|
||||
@@ -1744,36 +1741,39 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
}
|
||||
else if (row == USER_INTERFACE_THEME_INDEX)
|
||||
{
|
||||
uiThemeCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellWithCheckBoxes defaultReuseIdentifier] forIndexPath:indexPath];
|
||||
|
||||
uiThemeCell.mainContainerLeadingConstraint.constant = uiThemeCell.separatorInset.left;
|
||||
|
||||
uiThemeCell.checkBoxesNumber = 2;
|
||||
|
||||
uiThemeCell.allowsMultipleSelection = NO;
|
||||
uiThemeCell.delegate = self;
|
||||
|
||||
NSArray *labels = uiThemeCell.labels;
|
||||
UILabel *label;
|
||||
label = labels[0];
|
||||
label.textColor = kRiotPrimaryTextColor;
|
||||
label.text = NSLocalizedStringFromTable(@"settings_ui_light_theme", @"Vector", nil);
|
||||
label = labels[1];
|
||||
label.textColor = kRiotPrimaryTextColor;
|
||||
label.text = NSLocalizedStringFromTable(@"settings_ui_dark_theme", @"Vector", nil);
|
||||
|
||||
NSString *selectedTheme = [[NSUserDefaults standardUserDefaults] stringForKey:@"userInterfaceTheme"];
|
||||
if (selectedTheme && [selectedTheme isEqualToString:@"dark"])
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:kSettingsViewControllerPhoneBookCountryCellId];
|
||||
if (!cell)
|
||||
{
|
||||
[uiThemeCell setCheckBoxValue:YES atIndex:1];
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kSettingsViewControllerPhoneBookCountryCellId];
|
||||
}
|
||||
else
|
||||
|
||||
NSString *theme = [[NSUserDefaults standardUserDefaults] stringForKey:@"userInterfaceTheme"];
|
||||
if (!theme)
|
||||
{
|
||||
// Consider the light theme by default.
|
||||
[uiThemeCell setCheckBoxValue:YES atIndex:0];
|
||||
if (@available(iOS 11.0, *))
|
||||
{
|
||||
// "auto" is used the default value from iOS 11
|
||||
theme = @"auto";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use "light" for older version
|
||||
theme = @"light";
|
||||
}
|
||||
}
|
||||
|
||||
cell = uiThemeCell;
|
||||
|
||||
theme = [NSString stringWithFormat:@"settings_ui_theme_%@", theme];
|
||||
NSString *i18nTheme = NSLocalizedStringFromTable(theme,
|
||||
@"Vector",
|
||||
nil);
|
||||
|
||||
cell.textLabel.textColor = kRiotPrimaryTextColor;
|
||||
|
||||
cell.textLabel.text = NSLocalizedStringFromTable(@"settings_ui_theme", @"Vector", nil);
|
||||
cell.detailTextLabel.text = i18nTheme;
|
||||
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
|
||||
}
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX)
|
||||
@@ -1915,6 +1915,18 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
|
||||
cell = sendCrashReportCell;
|
||||
}
|
||||
else if (row == OTHER_ENABLE_RAGESHAKE_INDEX)
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSwitch* enableRageShakeCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
|
||||
|
||||
enableRageShakeCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_enable_rageshake", @"Vector", nil);
|
||||
enableRageShakeCell.mxkSwitch.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableRageShake"];
|
||||
enableRageShakeCell.mxkSwitch.enabled = YES;
|
||||
[enableRageShakeCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
|
||||
[enableRageShakeCell.mxkSwitch addTarget:self action:@selector(toggleEnableRageShake:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
cell = enableRageShakeCell;
|
||||
}
|
||||
else if (row == OTHER_MARK_ALL_AS_READ_INDEX)
|
||||
{
|
||||
MXKTableViewCellWithButton *markAllBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]];
|
||||
@@ -2005,7 +2017,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
|
||||
cell = labelAndSwitchCell;
|
||||
}
|
||||
#ifdef USE_JITSI_WIDGET
|
||||
else if (row == LABS_USE_JITSI_WIDGET_INDEX)
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
|
||||
@@ -2018,9 +2029,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
|
||||
cell = labelAndSwitchCell;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (row == LABS_CRYPTO_INDEX)
|
||||
else if (row == LABS_CRYPTO_INDEX)
|
||||
{
|
||||
MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0];
|
||||
|
||||
@@ -2340,6 +2349,10 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
languagePickerViewController.delegate = self;
|
||||
[self pushViewController:languagePickerViewController];
|
||||
}
|
||||
else if (row == USER_INTERFACE_THEME_INDEX)
|
||||
{
|
||||
[self showThemePicker];
|
||||
}
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX)
|
||||
{
|
||||
@@ -2792,6 +2805,19 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)toggleEnableRageShake:(id)sender
|
||||
{
|
||||
if (sender && [sender isKindOfClass:UISwitch.class])
|
||||
{
|
||||
UISwitch *switchButton = (UISwitch*)sender;
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setBool:switchButton.isOn forKey:@"enableRageShake"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)toggleLabsMatrixApps:(id)sender
|
||||
{
|
||||
if (sender && [sender isKindOfClass:UISwitch.class])
|
||||
@@ -3512,6 +3538,90 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showThemePicker
|
||||
{
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
__block UIAlertAction *autoAction, *lightAction, *darkAction;
|
||||
NSString *themePickerMessage;
|
||||
|
||||
void (^actionBlock)(UIAlertAction *action) = ^(UIAlertAction * action) {
|
||||
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
|
||||
NSString *newTheme;
|
||||
if (action == autoAction)
|
||||
{
|
||||
newTheme = @"auto";
|
||||
}
|
||||
else if (action == lightAction)
|
||||
{
|
||||
newTheme = @"light";
|
||||
}
|
||||
else if (action == darkAction)
|
||||
{
|
||||
newTheme = @"dark";
|
||||
}
|
||||
|
||||
NSString *theme = [[NSUserDefaults standardUserDefaults] stringForKey:@"userInterfaceTheme"];
|
||||
if (newTheme && ![newTheme isEqualToString:theme])
|
||||
{
|
||||
// Clear fake Riot Avatars based on the previous theme.
|
||||
[AvatarGenerator clear];
|
||||
|
||||
// The user wants to select this theme
|
||||
[[NSUserDefaults standardUserDefaults] setObject:newTheme forKey:@"userInterfaceTheme"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (@available(iOS 11.0, *))
|
||||
{
|
||||
// Show "auto" only from iOS 11
|
||||
autoAction = [UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"settings_ui_theme_auto", @"Vector", nil)
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:actionBlock];
|
||||
|
||||
// Explain what is "auto"
|
||||
themePickerMessage = NSLocalizedStringFromTable(@"settings_ui_theme_picker_message", @"Vector", nil);
|
||||
}
|
||||
|
||||
lightAction = [UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"settings_ui_theme_light", @"Vector", nil)
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:actionBlock];
|
||||
|
||||
darkAction = [UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"settings_ui_theme_dark", @"Vector", nil)
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:actionBlock];
|
||||
|
||||
UIAlertController *themePicker = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"settings_ui_theme_picker_title", @"Vector", nil)
|
||||
message:themePickerMessage
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
|
||||
if (autoAction)
|
||||
{
|
||||
[themePicker addAction:autoAction];
|
||||
}
|
||||
[themePicker addAction:lightAction];
|
||||
[themePicker addAction:darkAction];
|
||||
|
||||
// Cancel button
|
||||
[themePicker addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:nil]];
|
||||
|
||||
UIView *fromCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:USER_INTERFACE_THEME_INDEX inSection:SETTINGS_SECTION_USER_INTERFACE_INDEX]];
|
||||
[themePicker popoverPresentationController].sourceView = fromCell;
|
||||
[themePicker popoverPresentationController].sourceRect = fromCell.bounds;
|
||||
|
||||
[self presentViewController:themePicker animated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - MediaPickerViewController Delegate
|
||||
|
||||
- (void)dismissMediaPicker
|
||||
@@ -3851,25 +3961,4 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - TableViewCellWithCheckBoxesDelegate
|
||||
|
||||
- (void)tableViewCellWithCheckBoxes:(TableViewCellWithCheckBoxes *)tableViewCellWithCheckBoxes didTapOnCheckBoxAtIndex:(NSUInteger)index
|
||||
{
|
||||
if (tableViewCellWithCheckBoxes == uiThemeCell)
|
||||
{
|
||||
NSString *theme = (index == 0) ? @"light" : @"dark";
|
||||
BOOL isCurrentlySelected = [uiThemeCell checkBoxValueAtIndex:index];
|
||||
|
||||
if (!isCurrentlySelected)
|
||||
{
|
||||
// Clear fake Riot Avatars based on the previous theme.
|
||||
[AvatarGenerator clear];
|
||||
|
||||
// The user wants to select this theme
|
||||
[[NSUserDefaults standardUserDefaults] setObject:theme forKey:@"userInterfaceTheme"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user