Settings: Add 'mark all as read' option

#541
This commit is contained in:
giomfo 2016-08-26 16:12:46 +02:00
parent 9a1d5d0c75
commit 8c044445b0
5 changed files with 73 additions and 19 deletions

View file

@ -83,6 +83,9 @@ extern NSString *const kAppDelegateNetworkStatusDidChangeNotification;
// Remove a matrix session.
- (void)removeMatrixSession:(MXSession*)mxSession;
// Mark all messages as read in the running matrix sessions.
- (void)markAllMessagesAsRead;
// Reload all running matrix sessions
- (void)reloadMatrixSessions:(BOOL)clearCache;

View file

@ -1457,6 +1457,11 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
[mxSessionArray removeObject:mxSession];
}
- (void)markAllMessagesAsRead
{
[MXKRoomDataSourceManager markAllMessagesAsRead];
}
- (void)reloadMatrixSessions:(BOOL)clearCache
{
// Reload all running matrix sessions

View file

@ -20,7 +20,6 @@
// Actions
"view" = "View";
"mark_all_as_read_prompt" = "Mark all as read?";
"next" = "Next";
"back" = "Back";
"continue" = "Continue";
@ -195,6 +194,7 @@
"account_logout_all" = "Logout all accounts";
"settings_config_no_build_info" = "(no build info)";
"settings_mark_all_as_read" = "Mark all messages as read";
"settings_clear_cache" = "Clear cache";
"settings_config_home_server" = "Home server is %@";
"settings_config_identity_server" = "Identity server is %@";

View file

@ -1890,7 +1890,7 @@ NSString *const kRoomSettingsAdvancedCellViewIdentifier = @"kRoomSettingsAdvance
[leaveCell.mxkButton setTitle:title forState:UIControlStateNormal];
[leaveCell.mxkButton setTitle:title forState:UIControlStateHighlighted];
[leaveCell.mxkButton setTintColor:kVectorColorGreen];
leaveCell.mxkButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
leaveCell.mxkButton.titleLabel.font = [UIFont systemFontOfSize:17];
[leaveCell.mxkButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[leaveCell.mxkButton addTarget:self action:@selector(onLeave:) forControlEvents:UIControlEventTouchUpInside];

View file

@ -46,13 +46,14 @@
//#define NOTIFICATION_SETTINGS_CALL_INVITATION_INDEX 6
#define NOTIFICATION_SETTINGS_COUNT 2
#define OTHER_VERSION_INDEX 0
#define OTHER_TERM_CONDITIONS_INDEX 1
#define OTHER_PRIVACY_INDEX 2
#define OTHER_THIRD_PARTY_INDEX 3
#define OTHER_CRASH_REPORT_INDEX 4
#define OTHER_CLEAR_CACHE_INDEX 5
#define OTHER_COUNT 6
#define OTHER_VERSION_INDEX 0
#define OTHER_TERM_CONDITIONS_INDEX 1
#define OTHER_PRIVACY_INDEX 2
#define OTHER_THIRD_PARTY_INDEX 3
#define OTHER_CRASH_REPORT_INDEX 4
#define OTHER_MARK_ALL_AS_READ_INDEX 5
#define OTHER_CLEAR_CACHE_INDEX 6
#define OTHER_COUNT 7
#define LABS_VOIP_INDEX 0
#define LABS_CONFERENCE_CALL_INDEX 1
@ -653,7 +654,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
[signOutCell.mxkButton setTitle:title forState:UIControlStateNormal];
[signOutCell.mxkButton setTitle:title forState:UIControlStateHighlighted];
[signOutCell.mxkButton setTintColor:kVectorColorGreen];
signOutCell.mxkButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
signOutCell.mxkButton.titleLabel.font = [UIFont systemFontOfSize:17];
[signOutCell.mxkButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[signOutCell.mxkButton addTarget:self action:@selector(onSignout:) forControlEvents:UIControlEventTouchUpInside];
@ -964,6 +965,25 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
cell = sendCrashReportCell;
}
else if (row == OTHER_MARK_ALL_AS_READ_INDEX)
{
MXKTableViewCellWithButton *markAllBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]];
if (!markAllBtnCell)
{
markAllBtnCell = [[MXKTableViewCellWithButton alloc] init];
}
NSString *btnTitle = NSLocalizedStringFromTable(@"settings_mark_all_as_read", @"Vector", nil);
[markAllBtnCell.mxkButton setTitle:btnTitle forState:UIControlStateNormal];
[markAllBtnCell.mxkButton setTitle:btnTitle forState:UIControlStateHighlighted];
[markAllBtnCell.mxkButton setTintColor:kVectorColorGreen];
markAllBtnCell.mxkButton.titleLabel.font = [UIFont systemFontOfSize:17];
[markAllBtnCell.mxkButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[markAllBtnCell.mxkButton addTarget:self action:@selector(markAllAsRead:) forControlEvents:UIControlEventTouchUpInside];
cell = markAllBtnCell;
}
else if (row == OTHER_CLEAR_CACHE_INDEX)
{
MXKTableViewCellWithButton *clearCacheBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]];
@ -972,13 +992,14 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
clearCacheBtnCell = [[MXKTableViewCellWithButton alloc] init];
}
NSString *btnTitle = [NSString stringWithFormat:@"%@", NSLocalizedStringFromTable(@"settings_clear_cache", @"Vector", nil)];
NSString *btnTitle = NSLocalizedStringFromTable(@"settings_clear_cache", @"Vector", nil);
[clearCacheBtnCell.mxkButton setTitle:btnTitle forState:UIControlStateNormal];
[clearCacheBtnCell.mxkButton setTitle:btnTitle forState:UIControlStateHighlighted];
[clearCacheBtnCell.mxkButton setTintColor:kVectorColorGreen];
clearCacheBtnCell.mxkButton.titleLabel.font = [UIFont systemFontOfSize:17];
[clearCacheBtnCell.mxkButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[clearCacheBtnCell.mxkButton addTarget:self action:@selector(onClearCache:) forControlEvents:UIControlEventTouchUpInside];
[clearCacheBtnCell.mxkButton addTarget:self action:@selector(clearCache:) forControlEvents:UIControlEventTouchUpInside];
cell = clearCacheBtnCell;
}
@ -1238,13 +1259,12 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
- (void)onSignout:(id)sender
{
UIButton *signOutButton = (UIButton*)sender;
[signOutButton setTintColor:[UIColor lightGrayColor]];
signOutButton.enabled = NO;
// Feedback: disable button and run activity indicator
UIButton *button = (UIButton*)sender;
button.enabled = NO;
[self startActivityIndicator];
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[MXKAccountManager sharedManager] logout];
@ -1384,9 +1404,35 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
}
}
- (void)onClearCache:(id)sender
- (void)markAllAsRead:(id)sender
{
[[AppDelegate theDelegate] reloadMatrixSessions:YES];
// Feedback: disable button and run activity indicator
UIButton *button = (UIButton*)sender;
button.enabled = NO;
[self startActivityIndicator];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[AppDelegate theDelegate] markAllMessagesAsRead];
[self stopActivityIndicator];
button.enabled = YES;
});
}
- (void)clearCache:(id)sender
{
// Feedback: disable button and run activity indicator
UIButton *button = (UIButton*)sender;
button.enabled = NO;
[self startActivityIndicator];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[AppDelegate theDelegate] reloadMatrixSessions:YES];
});
}
//- (void)onRuleUpdate:(id)sender