From 922382f51284823513405ab3c030589133b3192b Mon Sep 17 00:00:00 2001 From: yannick Date: Mon, 7 Dec 2015 16:05:50 +0100 Subject: [PATCH 01/13] user_settings_page -> first implementation --> the tableview is the same as the screenshot we have --> the push rules can be toggled Need to manage the account updates. --- Vector/Assets/en.lproj/Vector.strings | 30 + .../ViewController/SettingsViewController.h | 5 +- .../ViewController/SettingsViewController.m | 704 ++++++++++++++---- 3 files changed, 589 insertions(+), 150 deletions(-) diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 35074b194..ab3f4fe5c 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -28,6 +28,9 @@ "leave" = "Leave"; "remove" = "Remove"; "retry" = "Retry"; +"on" = "On"; +"off" = "Off"; +"cancel" = "Cancel"; // Authentication "auth_sign_in" = "Sign in"; @@ -87,6 +90,33 @@ "settings_title_config" = "Configuration"; "settings_clear_cache" = "Clear cache"; +"settings_user_settings" = "USER SETTINGS"; +"settings_notifications_settings" = "NOTIFICATION SETTINGS"; +"settings_other" = "OTHER"; + +"settings_sign_out" = "Sign Out"; +"settings_profile_picture" = "Profile Picture"; +"settings_display_name" = "Display Name"; +"settings_first_name" = "First Name"; +"settings_surname" = "Surname"; +"settings_email_address" = "Email Address"; +"settings_change_password" = "Change password"; +"settings_phone_number" = "Phone Number"; +"settings_night_mode" = "Night Mode"; + +"settings_enable_all_notif" = "Enable all notifications"; +"settings_general_messages" = "General messages"; +"settings_messages_my_name" = "Messages containing my name"; +"settings_messages_sent_to_me" = "Messages sent to me"; +"settings_invited_to_room" = "When i'm invited to a room"; +"settings_join_leave_rooms" = "When people join or leave rooms"; +"settings_call_invitations" = "Call invitations"; + +"settings_version" = "Version %@"; +"settings_term_conditions" = "Terms & conditions"; +"settings_privacy_policy" = "Privacy Policy"; +"settings_clear_cache" = "Clear cache"; + // Room Details "room_details_title" = "Room Details"; "room_details_room_name" = "Room Name"; diff --git a/Vector/ViewController/SettingsViewController.h b/Vector/ViewController/SettingsViewController.h index 5650aac2d..6dd75c1a5 100644 --- a/Vector/ViewController/SettingsViewController.h +++ b/Vector/ViewController/SettingsViewController.h @@ -16,7 +16,10 @@ #import -@interface SettingsViewController : MXKTableViewController +#import "MediaPickerViewController.h" + +@interface SettingsViewController : MXKTableViewController + @end diff --git a/Vector/ViewController/SettingsViewController.m b/Vector/ViewController/SettingsViewController.m index 2afd5049a..7741a9b0c 100644 --- a/Vector/ViewController/SettingsViewController.m +++ b/Vector/ViewController/SettingsViewController.m @@ -20,17 +20,61 @@ #import "AppDelegate.h" -#define SETTINGS_SECTION_ACCOUNTS_INDEX 0 -#define SETTINGS_SECTION_CONFIGURATION_INDEX 1 -#define SETTINGS_SECTION_COUNT 2 +#import "VectorDesignValues.h" + +#import "AvatarGenerator.h" + +#define SETTINGS_SECTION_SIGN_OUT_INDEX 0 +#define SETTINGS_SECTION_USER_SETTINGS_INDEX 1 +#define SETTINGS_SECTION_NOTIFICATIONS_SETTINGS_INDEX 2 +#define SETTINGS_SECTION_OTHER_INDEX 3 +#define SETTINGS_SECTION_COUNT 4 + + +#define USER_SETTINGS_PROFILE_PICTURE_INDEX 0 +#define USER_SETTINGS_DISPLAY_NAME_INDEX 1 +#define USER_SETTINGS_FIRST_NAME_INDEX 2 +#define USER_SETTINGS_SURNAME_INDEX 3 +#define USER_SETTINGS_EMAIL_ADDRESS_INDEX 4 +#define USER_SETTINGS_CHANGE_PASSWORD_INDEX 5 +#define USER_SETTINGS_PHONE_NUMBER_INDEX 6 +#define USER_SETTINGS_NIGHT_MODE_SEP_INDEX 7 +#define USER_SETTINGS_NIGHT_MODE_INDEX 8 +#define USER_SETTINGS_COUNT 9 + +#define NOTIFICATION_SETTINGS_ENABLE_ALL_INDEX 0 +#define NOTIFICATION_SETTINGS_CONTAINING_MY_NAME_INDEX 1 +#define NOTIFICATION_SETTINGS_SENT_TO_ME_INDEX 2 +#define NOTIFICATION_SETTINGS_INVITED_TO_ROOM_INDEX 3 +#define NOTIFICATION_SETTINGS_PEOPLE_LEAVE_JOIN_INDEX 4 +#define NOTIFICATION_SETTINGS_CALL_INVITATION_INDEX 5 +#define NOTIFICATION_SETTINGS_COUNT 6 + +#define OTHER_VERSION_INDEX 0 +#define OTHER_TERM_CONDITIONS_INDEX 1 +#define OTHER_PRIVACY_INDEX 2 +#define OTHER_CLEAR_CACHE_INDEX 3 +#define OTHER_COUNT 4 + @interface SettingsViewController () { - MXKAccount *selectedAccount; + // listener id removedAccountObserver; id accountUserInfoObserver; + id apnsInfoUpdateObserver; + + id notificationCenterWillUpdateObserver; + id notificationCenterDidUpdateObserver; + id notificationCenterDidFailObserver; + + // picker + MediaPickerViewController* mediaPicker; + + // temporary data + UIImage* newThumbnailImage; + NSURL* newThumbnailimageURL; - UIButton *clearCacheButton; } @end @@ -45,6 +89,8 @@ // Setup `MXKRoomMemberListViewController` properties self.rageShakeManager = [RageShakeManager sharedManager]; + self.tableView.backgroundColor = VECTOR_LIGHT_GRAY_COLOR; + // Add observer to handle removed accounts removedAccountObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXKAccountManagerDidRemoveAccountNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { @@ -77,10 +123,18 @@ // Add observer to handle accounts update accountUserInfoObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXKAccountUserInfoDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { - // Refresh table to remove this account + [self stopActivityIndicator]; [self.tableView reloadData]; }]; - + + // Add observer to apns + apnsInfoUpdateObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXKAccountAPNSActivityDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { + + [self stopActivityIndicator]; + [self.tableView reloadData]; + }]; + + // Add each matrix session, to update the view controller appearance according to mx sessions state NSArray *sessions = [AppDelegate theDelegate].mxSessions; for (MXSession *mxSession in sessions) @@ -122,6 +176,40 @@ { [super viewWillAppear:animated]; + if ([MXKAccountManager sharedManager].activeAccounts.count > 0) + { + MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; + + // Refresh existing notification rules + [account.mxSession.notificationCenter refreshRules:^{ + + [self stopActivityIndicator]; + [self.tableView reloadData]; + + } failure:^(NSError *error) { + + [self stopActivityIndicator]; + + }]; + + notificationCenterWillUpdateObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXNotificationCenterWillUpdateRules object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { + [self startActivityIndicator]; + }]; + + notificationCenterDidUpdateObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXNotificationCenterDidUpdateRules object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { + [self stopActivityIndicator]; + [self.tableView reloadData]; + }]; + + notificationCenterDidFailObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXNotificationCenterDidFailRulesUpdate object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { + [self stopActivityIndicator]; + + // Notify MatrixKit user + [[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:note.userInfo[kMXNotificationCenterErrorKey]]; + }]; + } + + // Refresh display [self.tableView reloadData]; } @@ -129,6 +217,25 @@ - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; + + if (notificationCenterWillUpdateObserver) + { + [[NSNotificationCenter defaultCenter] removeObserver:notificationCenterWillUpdateObserver]; + notificationCenterWillUpdateObserver = nil; + } + + if (notificationCenterDidUpdateObserver) + { + [[NSNotificationCenter defaultCenter] removeObserver:notificationCenterDidUpdateObserver]; + notificationCenterDidUpdateObserver = nil; + } + + if (notificationCenterDidFailObserver) + { + [[NSNotificationCenter defaultCenter] removeObserver:notificationCenterDidFailObserver]; + notificationCenterDidFailObserver = nil; + } + } #pragma mark - Internal methods @@ -148,11 +255,13 @@ accountUserInfoObserver = nil; } - [[NSNotificationCenter defaultCenter] removeObserver:self]; + if (apnsInfoUpdateObserver) + { + [[NSNotificationCenter defaultCenter] removeObserver:apnsInfoUpdateObserver]; + apnsInfoUpdateObserver = nil; + } - selectedAccount = nil; - - clearCacheButton = nil; + [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (IBAction)onAccountToggleChange:(id)sender @@ -171,27 +280,6 @@ }); } -#pragma mark - Actions - -- (IBAction)addAccount:(id)sender -{ - [self performSegueWithIdentifier:@"addAccount" sender:self]; -} - -- (IBAction)logout:(id)sender -{ - // Logout all matrix account - [[MXKAccountManager sharedManager] logout]; -} - -- (IBAction)onButtonPressed:(id)sender -{ - if (sender == clearCacheButton) - { - [[AppDelegate theDelegate] reloadMatrixSessions:YES]; - } -} - #pragma mark - Segues - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender @@ -201,9 +289,9 @@ if ([[segue identifier] isEqualToString:@"showAccountDetails"]) { - MXKAccountDetailsViewController *accountViewController = segue.destinationViewController; - accountViewController.mxAccount = selectedAccount; - selectedAccount = nil; + //MXKAccountDetailsViewController *accountViewController = segue.destinationViewController; + //accountViewController.mxAccount = selectedAccount; + //selectedAccount = nil; } } @@ -217,83 +305,313 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSInteger count = 0; - if (section == SETTINGS_SECTION_ACCOUNTS_INDEX) + + if (section == SETTINGS_SECTION_SIGN_OUT_INDEX) { - // manage one account by now - count = [[MXKAccountManager sharedManager] accounts].count; //+ 1; // Add one cell in this section to display "logout all" option. + count = 1; } - else if (section == SETTINGS_SECTION_CONFIGURATION_INDEX) + else if (section == SETTINGS_SECTION_USER_SETTINGS_INDEX) { - count = 2; + count = USER_SETTINGS_COUNT; + } + else if (section == SETTINGS_SECTION_NOTIFICATIONS_SETTINGS_INDEX) + { + count = NOTIFICATION_SETTINGS_COUNT; + } + else if (section == SETTINGS_SECTION_OTHER_INDEX) + { + count = OTHER_COUNT; } return count; } +- (MXKTableViewCellWithLabelAndTextField*)getLabelAndTextFieldCell:(UITableView*)tableview +{ + MXKTableViewCellWithLabelAndTextField *cell = [tableview dequeueReusableCellWithIdentifier:[MXKTableViewCellWithLabelAndTextField defaultReuseIdentifier]]; + + if (!cell) + { + cell = [[MXKTableViewCellWithLabelAndTextField alloc] init]; + } + + cell.mxkTextField.userInteractionEnabled = YES; + cell.mxkTextField.borderStyle = UITextBorderStyleNone; + cell.mxkTextField.textAlignment = NSTextAlignmentRight; + cell.mxkTextField.textColor = [UIColor lightGrayColor]; + + cell.accessoryType = UITableViewCellAccessoryNone; + + cell.alpha = 1.0f; + cell.userInteractionEnabled = YES; + + return cell; +} + +- (MXKTableViewCellWithLabelAndSwitch*)getLabelAndSwitchCell:(UITableView*)tableview +{ + MXKTableViewCellWithLabelAndSwitch *cell = [tableview dequeueReusableCellWithIdentifier:[MXKTableViewCellWithLabelAndSwitch defaultReuseIdentifier]]; + + if (!cell) + { + cell = [[MXKTableViewCellWithLabelAndSwitch alloc] init]; + } + + return cell; +} + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = nil; + NSInteger section = indexPath.section; + NSInteger row = indexPath.row; + + // set the cell to a default value to avoid application crashes + UITableViewCell *cell = [[UITableViewCell alloc] init]; + cell.backgroundColor = [UIColor redColor]; - if (indexPath.section == SETTINGS_SECTION_ACCOUNTS_INDEX) + // check if there is a valid session + if (([AppDelegate theDelegate].mxSessions.count == 0) || ([MXKAccountManager sharedManager].activeAccounts.count == 0)) { - NSArray *accounts = [[MXKAccountManager sharedManager] accounts]; - if (indexPath.row < accounts.count) - { - MXKAccountTableViewCell *accountCell = [tableView dequeueReusableCellWithIdentifier:[MXKAccountTableViewCell defaultReuseIdentifier]]; - if (!accountCell) - { - accountCell = [[MXKAccountTableViewCell alloc] init]; - } - - accountCell.mxAccount = [accounts objectAtIndex:indexPath.row]; - - // Display switch toggle in case of multiple accounts - if (accounts.count > 1 || accountCell.mxAccount.disabled) - { - accountCell.accountSwitchToggle.tag = indexPath.row; - accountCell.accountSwitchToggle.hidden = NO; - [accountCell.accountSwitchToggle addTarget:self action:@selector(onAccountToggleChange:) forControlEvents:UIControlEventValueChanged]; - } - - cell = accountCell; - } - /*else - { - MXKTableViewCellWithButton *logoutBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]]; - if (!logoutBtnCell) - { - logoutBtnCell = [[MXKTableViewCellWithButton alloc] init]; - } - [logoutBtnCell.mxkButton setTitle:NSLocalizedStringFromTable(@"account_logout_all", @"Vector", nil) forState:UIControlStateNormal]; - [logoutBtnCell.mxkButton setTitle:NSLocalizedStringFromTable(@"account_logout_all", @"Vector", nil) forState:UIControlStateHighlighted]; - - [logoutBtnCell.mxkButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; - [logoutBtnCell.mxkButton addTarget:self action:@selector(logout:) forControlEvents:UIControlEventTouchUpInside]; - - cell = logoutBtnCell; - }*/ + // else use a default cell + return cell; } - else if (indexPath.section == SETTINGS_SECTION_CONFIGURATION_INDEX) + + MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; + + if (section == SETTINGS_SECTION_SIGN_OUT_INDEX) { - if (indexPath.row == 0) + MXKTableViewCellWithButton *signOutCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]]; + if (!signOutCell) { - MXKTableViewCellWithTextView *configurationCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]]; - if (!configurationCell) + signOutCell = [[MXKTableViewCellWithButton alloc] init]; + } + + NSString* title = NSLocalizedStringFromTable(@"settings_sign_out", @"Vector", nil); + + [signOutCell.mxkButton setTitle:title forState:UIControlStateNormal]; + [signOutCell.mxkButton setTitle:title forState:UIControlStateHighlighted]; + [signOutCell.mxkButton setTintColor:VECTOR_GREEN_COLOR]; + signOutCell.mxkButton.titleLabel.font = [UIFont boldSystemFontOfSize:16]; + + [signOutCell.mxkButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; + [signOutCell.mxkButton addTarget:self action:@selector(onSignout:) forControlEvents:UIControlEventTouchUpInside]; + + cell = signOutCell; + } + else if (section == SETTINGS_SECTION_USER_SETTINGS_INDEX) + { + MXMyUser* myUser = session.myUser; + + if (row == USER_SETTINGS_PROFILE_PICTURE_INDEX) + { + MXKTableViewCellWithLabelAndMXKImageView *profileCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithLabelAndMXKImageView defaultReuseIdentifier]]; + + if (!profileCell) { - configurationCell = [[MXKTableViewCellWithTextView alloc] init]; + profileCell = [[MXKTableViewCellWithLabelAndMXKImageView alloc] init]; } + profileCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_profile_picture", @"Vector", nil); + + // if the user defines a new avatar + if (newThumbnailImage) + { + profileCell.mxkImageView.image = newThumbnailImage; + } + else + { + UIImage* avatarImage = [AvatarGenerator generateRoomMemberAvatar:myUser.userId displayName:myUser.displayname]; + + if (myUser.avatarUrl) + { + profileCell.mxkImageView.enableInMemoryCache = YES; + + [profileCell.mxkImageView setImageURL:[session.matrixRestClient urlOfContentThumbnail:myUser.avatarUrl toFitViewSize:profileCell.mxkImageView.frame.size withMethod:MXThumbnailingMethodCrop] withType:nil andImageOrientation:UIImageOrientationUp previewImage:avatarImage]; + } + else + { + profileCell.mxkImageView.image = avatarImage; + } + } + + [profileCell.mxkImageView.layer setCornerRadius:profileCell.mxkImageView.frame.size.width / 2]; + profileCell.mxkImageView.clipsToBounds = YES; + + cell = profileCell; + } + else if (row == USER_SETTINGS_DISPLAY_NAME_INDEX) + { + MXKTableViewCellWithLabelAndTextField *displaynameCell = [self getLabelAndTextFieldCell:tableView]; + + displaynameCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_display_name", @"Vector", nil); + displaynameCell.mxkTextField.text = myUser.displayname; + + cell = displaynameCell; + } + else if (row == USER_SETTINGS_FIRST_NAME_INDEX) + { + MXKTableViewCellWithLabelAndTextField *firstCell = [self getLabelAndTextFieldCell:tableView]; + + firstCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_first_name", @"Vector", nil); + firstCell.mxkTextField.userInteractionEnabled = NO; + + cell = firstCell; + } + else if (row == USER_SETTINGS_SURNAME_INDEX) + { + MXKTableViewCellWithLabelAndTextField *surnameCell = [self getLabelAndTextFieldCell:tableView]; + + surnameCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_surname", @"Vector", nil); + surnameCell.mxkTextField.userInteractionEnabled = NO; + + cell = surnameCell; + } + else if (row == USER_SETTINGS_EMAIL_ADDRESS_INDEX) + { + MXKTableViewCellWithLabelAndTextField *emailCell = [self getLabelAndTextFieldCell:tableView]; + + emailCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_email_address", @"Vector", nil); + emailCell.mxkTextField.userInteractionEnabled = NO; + + cell = emailCell; + } + else if (row == USER_SETTINGS_CHANGE_PASSWORD_INDEX) + { + MXKTableViewCellWithLabelAndTextField *passwordCell = [self getLabelAndTextFieldCell:tableView]; + + passwordCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_change_password", @"Vector", nil); + passwordCell.mxkTextField.userInteractionEnabled = NO; + + cell = passwordCell; + } + else if (row == USER_SETTINGS_PHONE_NUMBER_INDEX) + { + MXKTableViewCellWithLabelAndTextField *phonenumberCell = [self getLabelAndTextFieldCell:tableView]; + + phonenumberCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_phone_number", @"Vector", nil); + phonenumberCell.mxkTextField.userInteractionEnabled = NO; + + cell = phonenumberCell; + } + else if (row == USER_SETTINGS_NIGHT_MODE_SEP_INDEX) + { + UITableViewCell *sepCell = [[UITableViewCell alloc] init]; + sepCell.backgroundColor = VECTOR_LIGHT_GRAY_COLOR; + + cell = sepCell; + } + else if (row == USER_SETTINGS_NIGHT_MODE_INDEX) + { + MXKTableViewCellWithLabelAndTextField *nightModeCell = [self getLabelAndTextFieldCell:tableView]; + + nightModeCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_night_mode", @"Vector", nil); + nightModeCell.mxkTextField.userInteractionEnabled = NO; + nightModeCell.mxkTextField.text = NSLocalizedStringFromTable(@"off", @"Vector", nil); + nightModeCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + cell = nightModeCell; + } + } + else if (section == SETTINGS_SECTION_NOTIFICATIONS_SETTINGS_INDEX) + { + + MXPushRule *rule; + + if (row == NOTIFICATION_SETTINGS_ENABLE_ALL_INDEX) + { + MXKTableViewCellWithLabelAndSwitch* enableAllCell = [self getLabelAndSwitchCell:tableView]; + + enableAllCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_enable_all_notif", @"Vector", nil); + enableAllCell.mxkSwitch.on = account.pushNotificationServiceIsActive; + + cell = enableAllCell; + } + else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_NAME_INDEX) + { + MXKTableViewCellWithLabelAndSwitch* myNameCell = [self getLabelAndSwitchCell:tableView]; + + myNameCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_messages_my_name", @"Vector", nil); + rule = [session.notificationCenter ruleById:kMXNotificationCenterContainDisplayNameRuleID]; + cell = myNameCell; + } + else if (row == NOTIFICATION_SETTINGS_SENT_TO_ME_INDEX) + { + MXKTableViewCellWithLabelAndSwitch* sentToMeCell = [self getLabelAndSwitchCell:tableView]; + sentToMeCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_messages_sent_to_me", @"Vector", nil); + rule = [session.notificationCenter ruleById:kMXNotificationCenterOneToOneRoomRuleID]; + cell = sentToMeCell; + } + else if (row == NOTIFICATION_SETTINGS_INVITED_TO_ROOM_INDEX) + { + MXKTableViewCellWithLabelAndSwitch* invitedToARoom = [self getLabelAndSwitchCell:tableView]; + invitedToARoom.mxkLabel.text = NSLocalizedStringFromTable(@"settings_invited_to_room", @"Vector", nil); + rule = [session.notificationCenter ruleById:kMXNotificationCenterInviteMeRuleID]; + cell = invitedToARoom; + } + else if (row == NOTIFICATION_SETTINGS_PEOPLE_LEAVE_JOIN_INDEX) + { + MXKTableViewCellWithLabelAndSwitch* peopleJoinLeaveCell = [self getLabelAndSwitchCell:tableView]; + peopleJoinLeaveCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_join_leave_rooms", @"Vector", nil); + rule = [session.notificationCenter ruleById:kMXNotificationCenterMemberEventRuleID]; + cell = peopleJoinLeaveCell; + } + else if (row == NOTIFICATION_SETTINGS_CALL_INVITATION_INDEX) + { + MXKTableViewCellWithLabelAndSwitch* callInvitationCell = [self getLabelAndSwitchCell:tableView]; + callInvitationCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_call_invitations", @"Vector", nil); + rule = [session.notificationCenter ruleById:kMXNotificationCenterCallRuleID]; + cell = callInvitationCell; + } + + // common management + MXKTableViewCellWithLabelAndSwitch* switchCell = (MXKTableViewCellWithLabelAndSwitch*)cell; + switchCell.mxkSwitch.tag = row; + + if (rule) + { + switchCell.mxkSwitch.on = rule.enabled; + } + + [switchCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; + [switchCell.mxkSwitch addTarget:self action:@selector(onRuleUpdate:) forControlEvents:UIControlEventTouchUpInside]; + + } + else if (section == SETTINGS_SECTION_OTHER_INDEX) + { + if (row == OTHER_VERSION_INDEX) + { + MXKTableViewCellWithLabelAndTextField *versionCell = [self getLabelAndTextFieldCell:tableView]; + NSString* appVersion = [AppDelegate theDelegate].appVersion; NSString* build = [AppDelegate theDelegate].build; - if (build.length) - { - build = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_config_build_number", @"Vector", nil), build]; - } - NSString *configurationFormatText = [NSString stringWithFormat:@"%@\n%@\n%@\n%@", NSLocalizedStringFromTable(@"settings_config_ios_console_version", @"Vector", nil), NSLocalizedStringFromTable(@"settings_config_ios_kit_version", @"Vector", nil), NSLocalizedStringFromTable(@"settings_config_ios_sdk_version", @"Vector", nil), @"%@"]; - configurationCell.mxkTextView.text = [NSString stringWithFormat:configurationFormatText, appVersion, MatrixKitVersion, MatrixSDKVersion, build]; - cell = configurationCell; + + versionCell.mxkLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_version", @"Vector", nil), [NSString stringWithFormat:@"%@ %@", appVersion, build]]; + versionCell.mxkTextField.userInteractionEnabled = NO; + versionCell.mxkTextField.text = nil; + + cell = versionCell; } - else if (indexPath.row == 1) + else if (row == OTHER_TERM_CONDITIONS_INDEX) + { + MXKTableViewCellWithLabelAndTextField *termAndConditionCell = [self getLabelAndTextFieldCell:tableView]; + + termAndConditionCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_term_conditions", @"Vector", nil); + termAndConditionCell.mxkTextField.userInteractionEnabled = NO; + termAndConditionCell.mxkTextField.text = nil; + + cell = termAndConditionCell; + } + else if (row == OTHER_PRIVACY_INDEX) + { + MXKTableViewCellWithLabelAndTextField *privacyPolicyCell = [self getLabelAndTextFieldCell:tableView]; + + privacyPolicyCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_privacy_policy", @"Vector", nil); + privacyPolicyCell.mxkTextField.userInteractionEnabled = NO; + privacyPolicyCell.mxkTextField.text = nil; + + cell = privacyPolicyCell; + } + else if (row == OTHER_CLEAR_CACHE_INDEX) { MXKTableViewCellWithButton *clearCacheBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]]; if (!clearCacheBtnCell) @@ -305,10 +623,8 @@ [clearCacheBtnCell.mxkButton setTitle:btnTitle forState:UIControlStateNormal]; [clearCacheBtnCell.mxkButton setTitle:btnTitle forState:UIControlStateHighlighted]; - clearCacheButton = clearCacheBtnCell.mxkButton; - - [clearCacheButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; - [clearCacheButton addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; + [clearCacheBtnCell.mxkButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; + [clearCacheBtnCell.mxkButton addTarget:self action:@selector(onClearCache:) forControlEvents:UIControlEventTouchUpInside]; cell = clearCacheBtnCell; } @@ -321,73 +637,50 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section == SETTINGS_SECTION_ACCOUNTS_INDEX) - { - return 50; - } - else if (indexPath.section == SETTINGS_SECTION_CONFIGURATION_INDEX && indexPath.row == 0) - { - UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, MAXFLOAT)]; - textView.font = [UIFont systemFontOfSize:14]; - NSString* appVersion = [AppDelegate theDelegate].appVersion; - NSString* build = [AppDelegate theDelegate].build; - if (build.length) - { - build = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_config_build_number", @"Vector", nil), build]; - } - NSString *configurationFormatText = [NSString stringWithFormat:@"%@\n%@\n%@\n%@", NSLocalizedStringFromTable(@"settings_config_ios_console_version", @"Vector", nil), NSLocalizedStringFromTable(@"settings_config_ios_kit_version", @"Vector", nil), NSLocalizedStringFromTable(@"settings_config_ios_sdk_version", @"Vector", nil), @"%@"]; - textView.text = [NSString stringWithFormat:configurationFormatText, appVersion, MatrixKitVersion, MatrixSDKVersion, build]; - CGSize contentSize = [textView sizeThatFits:textView.frame.size]; - return contentSize.height + 1; - } - - return 44; + return 50; } - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - return 30; -} - -- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section -{ - return 1; + if (section == SETTINGS_SECTION_SIGN_OUT_INDEX) + { + return 30; + } + + return 60; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *sectionHeader = [[UIView alloc] initWithFrame:[tableView rectForHeaderInSection:section]]; - sectionHeader.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0]; - UILabel *sectionLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, sectionHeader.frame.size.width - 10, sectionHeader.frame.size.height - 10)]; + sectionHeader.backgroundColor = VECTOR_LIGHT_GRAY_COLOR; + + if (section == SETTINGS_SECTION_SIGN_OUT_INDEX) + { + return sectionHeader; + } + + UILabel *sectionLabel = [[UILabel alloc] init]; sectionLabel.font = [UIFont boldSystemFontOfSize:16]; sectionLabel.backgroundColor = [UIColor clearColor]; - [sectionHeader addSubview:sectionLabel]; - if (section == SETTINGS_SECTION_ACCOUNTS_INDEX) + if (section == SETTINGS_SECTION_USER_SETTINGS_INDEX) { - sectionLabel.text = NSLocalizedStringFromTable(@"account", @"Vector", nil); - - /*UIButton *addAccount = [UIButton buttonWithType:UIButtonTypeContactAdd]; - [addAccount addTarget:self action:@selector(addAccount:) forControlEvents:UIControlEventTouchUpInside]; - - CGRect frame = addAccount.frame; - frame.origin.x = sectionHeader.frame.size.width - frame.size.width - 8; - frame.origin.y = (sectionHeader.frame.size.height - frame.size.height) / 2; - addAccount.frame = frame; - - [sectionHeader addSubview:addAccount]; - addAccount.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin); - - sectionHeader.userInteractionEnabled = YES;*/ + sectionLabel.text = NSLocalizedStringFromTable(@"settings_user_settings", @"Vector", nil); } - else if (section == SETTINGS_SECTION_CONFIGURATION_INDEX) + else if (section == SETTINGS_SECTION_NOTIFICATIONS_SETTINGS_INDEX) { - sectionLabel.text = NSLocalizedStringFromTable(@"settings_title_config", @"Vector", nil); + sectionLabel.text = NSLocalizedStringFromTable(@"settings_notifications_settings", @"Vector", nil); } - else + else if (section == SETTINGS_SECTION_OTHER_INDEX) { - sectionHeader = nil; + sectionLabel.text = NSLocalizedStringFromTable(@"settings_other", @"Vector", nil); } + + [sectionLabel sizeToFit]; + sectionLabel.frame = CGRectMake(10, sectionHeader.frame.size.height - sectionLabel.frame.size.height - 5, sectionHeader.frame.size.width - 20, sectionLabel.frame.size.height); + [sectionHeader addSubview:sectionLabel]; + return sectionHeader; } @@ -395,18 +688,131 @@ { if (self.tableView == aTableView) { - if (indexPath.section == SETTINGS_SECTION_ACCOUNTS_INDEX) + NSInteger section = indexPath.section; + NSInteger row = indexPath.row; + + if (section == SETTINGS_SECTION_OTHER_INDEX) { - NSArray *accounts = [[MXKAccountManager sharedManager] accounts]; - if (indexPath.row < accounts.count) + if (row == OTHER_TERM_CONDITIONS_INDEX) + { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) otherButtonTitles:nil, nil]; + [alertView setMessage:NSLocalizedStringFromTable(@"settings_term_conditions", @"Vector", nil)]; + [alertView show]; + } + else if (row == OTHER_PRIVACY_INDEX) + { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) otherButtonTitles:nil, nil]; + [alertView setMessage:NSLocalizedStringFromTable(@"settings_privacy_policy", @"Vector", nil)]; + [alertView show]; + } + } + else if (section == SETTINGS_SECTION_USER_SETTINGS_INDEX) + { + if (row == USER_SETTINGS_PROFILE_PICTURE_INDEX) { - selectedAccount = [accounts objectAtIndex:indexPath.row]; + mediaPicker = [MediaPickerViewController mediaPickerViewController]; + mediaPicker.mediaTypes = @[(NSString *)kUTTypeImage]; + mediaPicker.multipleSelections = NO; + mediaPicker.selectionButtonCustomLabel = NSLocalizedStringFromTable(@"media_picker_attach", @"Vector", nil); + mediaPicker.delegate = self; + UINavigationController *navigationController = [UINavigationController new]; + [navigationController pushViewController:mediaPicker animated:NO]; - [self performSegueWithIdentifier:@"showAccountDetails" sender:self]; + [self presentViewController:navigationController animated:YES completion:nil]; } } + [aTableView deselectRowAtIndexPath:indexPath animated:YES]; } } +#pragma mark - actions + +- (void)onSignout:(id)sender +{ + [[MXKAccountManager sharedManager] logout]; +} + +- (void)onClearCache:(id)sender +{ + [[AppDelegate theDelegate] reloadMatrixSessions:YES]; +} + +- (void)onRuleUpdate:(id)sender +{ + MXPushRule* pushRule = nil; + MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; + + NSInteger row = ((UIView*)sender).tag; + + if (row == NOTIFICATION_SETTINGS_ENABLE_ALL_INDEX) + { + [self startActivityIndicator]; + + // toggle the pushes + [account setEnablePushNotifications:!account.pushNotificationServiceIsActive]; + } + else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_NAME_INDEX) + { + pushRule = [session.notificationCenter ruleById:kMXNotificationCenterContainDisplayNameRuleID]; + } + else if (row == NOTIFICATION_SETTINGS_SENT_TO_ME_INDEX) + { + pushRule = [session.notificationCenter ruleById:kMXNotificationCenterOneToOneRoomRuleID]; + } + else if (row == NOTIFICATION_SETTINGS_INVITED_TO_ROOM_INDEX) + { + pushRule = [session.notificationCenter ruleById:kMXNotificationCenterInviteMeRuleID]; + } + else if (row == NOTIFICATION_SETTINGS_PEOPLE_LEAVE_JOIN_INDEX) + { + pushRule = [session.notificationCenter ruleById:kMXNotificationCenterMemberEventRuleID]; + } + else if (row == NOTIFICATION_SETTINGS_CALL_INVITATION_INDEX) + { + pushRule = [session.notificationCenter ruleById:kMXNotificationCenterCallRuleID]; + } + + if (pushRule) + { + // toggle the rule + [session.notificationCenter enableRule:pushRule isEnabled:!pushRule.enabled]; + } +} + +#pragma mark - MediaPickerViewController Delegate + +- (void)dismissMediaPicker +{ + if (mediaPicker) + { + [mediaPicker withdrawViewControllerAnimated:YES completion:nil]; + mediaPicker = nil; + } +} + +- (void)mediaPickerController:(MediaPickerViewController *)mediaPickerController didSelectImage:(UIImage*)image withURL:(NSURL *)imageURL +{ + [self dismissMediaPicker]; + + newThumbnailImage = image; + newThumbnailimageURL = imageURL; + + [self.tableView reloadData]; +} + +- (void)mediaPickerController:(MediaPickerViewController *)mediaPickerController didSelectVideo:(NSURL*)videoURL isCameraRecording:(BOOL)isCameraRecording +{ + // this method should not be called + [self dismissMediaPicker]; +} + +- (void)mediaPickerController:(MediaPickerViewController *)mediaPickerController didSelectAssets:(NSArray *)assets +{ + // this method should not be called + [self dismissMediaPicker]; +} + + @end From d4854cafe205a9303db83b14cd580c8522f3c232 Mon Sep 17 00:00:00 2001 From: yannick Date: Mon, 7 Dec 2015 17:40:16 +0100 Subject: [PATCH 02/13] Fix a compilation warning. --- Vector/Utils/AvatarGenerator.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vector/Utils/AvatarGenerator.m b/Vector/Utils/AvatarGenerator.m index 3b81ee0fc..61ff78e47 100644 --- a/Vector/Utils/AvatarGenerator.m +++ b/Vector/Utils/AvatarGenerator.m @@ -107,7 +107,7 @@ static UILabel* backgroundLabel = nil; // the images are cached to avoid create them several times // the key is // it should be smaller than using the text as a key - NSString* key = [NSString stringWithFormat:@"%@%ld", text, colorIndex]; + NSString* key = [NSString stringWithFormat:@"%@%tu", text, colorIndex]; if (!imageByKeyDict) { From 8f56adb196a6a0085ff719fe0ba2f05595c6577f Mon Sep 17 00:00:00 2001 From: yannick Date: Mon, 7 Dec 2015 17:45:19 +0100 Subject: [PATCH 03/13] The profile can be updated with the save button. --- .../ViewController/SettingsViewController.m | 201 +++++++++++++++--- 1 file changed, 177 insertions(+), 24 deletions(-) diff --git a/Vector/ViewController/SettingsViewController.m b/Vector/ViewController/SettingsViewController.m index 7741a9b0c..3ebcf7267 100644 --- a/Vector/ViewController/SettingsViewController.m +++ b/Vector/ViewController/SettingsViewController.m @@ -71,10 +71,17 @@ // picker MediaPickerViewController* mediaPicker; - // temporary data - UIImage* newThumbnailImage; - NSURL* newThumbnailimageURL; + // the first responder + UIView* firstResponder; + // profile updates + // avatar + UIImage* newAvatarImage; + // the avatar image has been uploaded + NSString* uploadedAvatarURL; + + // new displaynamed + NSString* newDisplayName; } @end @@ -141,6 +148,8 @@ { [self addMatrixSession:mxSession]; } + + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSave:)]; } - (void)didReceiveMemoryWarning @@ -264,22 +273,6 @@ [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (IBAction)onAccountToggleChange:(id)sender -{ - UISwitch *accountSwitchToggle = sender; - - NSArray *accounts = [[MXKAccountManager sharedManager] accounts]; - if (accountSwitchToggle.tag < accounts.count) - { - MXKAccount *account = [accounts objectAtIndex:accountSwitchToggle.tag]; - account.disabled = !accountSwitchToggle.on; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView reloadData]; - }); -} - #pragma mark - Segues - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender @@ -295,10 +288,27 @@ } } +#pragma mark - UIScrollView delegate + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + if (scrollView == self.tableView) + { + if ([firstResponder isFirstResponder]) + { + [firstResponder resignFirstResponder]; + firstResponder = nil; + } + } +} + #pragma mark - UITableView data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + // update the save button if there is an update + [self updateSaveButtonStatus]; + return SETTINGS_SECTION_COUNT; } @@ -415,9 +425,9 @@ profileCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_profile_picture", @"Vector", nil); // if the user defines a new avatar - if (newThumbnailImage) + if (newAvatarImage) { - profileCell.mxkImageView.image = newThumbnailImage; + profileCell.mxkImageView.image = newAvatarImage; } else { @@ -447,6 +457,13 @@ displaynameCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_display_name", @"Vector", nil); displaynameCell.mxkTextField.text = myUser.displayname; + displaynameCell.mxkTextField.tag = row; + [displaynameCell.mxkTextField removeTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; + [displaynameCell.mxkTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; + + [displaynameCell.mxkTextField removeTarget:self action:@selector(textFieldDidBegin:) forControlEvents:UIControlEventEditingDidBegin]; + [displaynameCell.mxkTextField addTarget:self action:@selector(textFieldDidBegin:) forControlEvents:UIControlEventEditingDidBegin]; + cell = displaynameCell; } else if (row == USER_SETTINGS_FIRST_NAME_INDEX) @@ -722,6 +739,12 @@ } } + if ([firstResponder isFirstResponder]) + { + [firstResponder resignFirstResponder]; + firstResponder = nil; + } + [aTableView deselectRowAtIndexPath:indexPath animated:YES]; } } @@ -781,6 +804,121 @@ } } +// +- (void)onSave:(id)sender +{ + [self startActivityIndicator]; + + MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; + MXMyUser* myUser = account.mxSession.myUser; + if (newDisplayName && ![myUser.displayname isEqualToString:newDisplayName]) + { + // Save display name + __weak typeof(self) weakSelf = self; + [account setUserDisplayName:newDisplayName success:^{ + + // Update the current displayname + __strong __typeof(weakSelf)strongSelf = weakSelf; + strongSelf->newDisplayName = nil; + + // Go to the next change saving step + [strongSelf onSave:nil]; + + } failure:^(NSError *error) { + + NSLog(@"[Vector Settings View Controller] Failed to set displayName: %@", error); + __strong __typeof(weakSelf)strongSelf = weakSelf; + + // Alert user + NSString *title = [error.userInfo valueForKey:NSLocalizedFailureReasonErrorKey]; + if (!title) + { + title = [NSBundle mxk_localizedStringForKey:@"account_error_display_name_change_failed"]; + } + NSString *msg = [error.userInfo valueForKey:NSLocalizedDescriptionKey]; + + MXKAlert *alert = [[MXKAlert alloc] initWithTitle:title message:msg style:MXKAlertStyleAlert]; +; + alert.cancelButtonIndex = [alert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"abort"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) + { + strongSelf->newDisplayName = nil; + // Loop to end saving + [strongSelf onSave:nil]; + }]; + [alert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"retry"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) + { + // Loop to retry saving + [strongSelf onSave:nil]; + }]; + [alert showInViewController:strongSelf]; + }]; + + return; + } + + if (newAvatarImage) + { + // Retrieve the current picture and make sure its orientation is up + UIImage *updatedPicture = [MXKTools forceImageOrientationUp:newAvatarImage]; + + // Upload picture + MXKMediaLoader *uploader = [MXKMediaManager prepareUploaderWithMatrixSession:account.mxSession initialRange:0 andRange:1.0]; + + [uploader uploadData:UIImageJPEGRepresentation(updatedPicture, 0.5) filename:nil mimeType:@"image/jpeg" success:^(NSString *url) + { + // Store uploaded picture url and trigger picture saving + uploadedAvatarURL = url; + newAvatarImage = nil; + + [self onSave:nil]; + } failure:^(NSError *error) + { + NSLog(@"[Vector SettingsViewController] Failed to upload image: %@", error); + uploadedAvatarURL = nil; + newAvatarImage = nil; + }]; + + } + else if (uploadedAvatarURL) + { + __weak typeof(self) weakSelf = self; + [account setUserAvatarUrl:uploadedAvatarURL + success:^{ + __strong __typeof(weakSelf)strongSelf = weakSelf; + strongSelf->uploadedAvatarURL = nil; + [strongSelf onSave:nil]; + } + failure:^(NSError *error) { + NSLog(@"[Vector SettingsViewController] Failed to set avatar url: %@", error); + + __strong __typeof(weakSelf)strongSelf = weakSelf; + strongSelf->uploadedAvatarURL = nil; + [strongSelf onSave:nil]; + }]; + } + + [self stopActivityIndicator]; + [self.tableView reloadData]; +} + +- (void)updateSaveButtonStatus +{ + MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXMyUser* myUser = session.myUser; + + BOOL saveButtonEnabled = (nil != newAvatarImage); + + if (!saveButtonEnabled) + { + if (newDisplayName) + { + saveButtonEnabled = ![myUser.displayname isEqualToString:newDisplayName]; + } + } + + self.navigationItem.rightBarButtonItem.enabled = saveButtonEnabled; +} + #pragma mark - MediaPickerViewController Delegate - (void)dismissMediaPicker @@ -795,9 +933,7 @@ - (void)mediaPickerController:(MediaPickerViewController *)mediaPickerController didSelectImage:(UIImage*)image withURL:(NSURL *)imageURL { [self dismissMediaPicker]; - - newThumbnailImage = image; - newThumbnailimageURL = imageURL; + newAvatarImage = image; [self.tableView reloadData]; } @@ -814,5 +950,22 @@ [self dismissMediaPicker]; } +#pragma mark - TextField listener + +- (IBAction)textFieldDidChange:(id)sender +{ + UITextField* textField = (UITextField*)sender; + + if (textField.tag == USER_SETTINGS_DISPLAY_NAME_INDEX) + { + newDisplayName = textField.text; + [self updateSaveButtonStatus]; + } +} + +- (IBAction)textFieldDidBegin:(id)sender +{ + firstResponder = (UIView*)sender; +} @end From 7c6057bfed131638072147053cac873c6d344193 Mon Sep 17 00:00:00 2001 From: giomfo Date: Tue, 8 Dec 2015 10:10:59 +0100 Subject: [PATCH 04/13] Chat screen: Update bubble layout -Define all required cell view classes -Disable timestamp display (TODO display timestamp for last message, and selected message if any). --- Vector.xcodeproj/project.pbxproj | 100 +++++++-- Vector/Model/Room/RoomBubbleCellData.m | 143 +------------ Vector/ViewController/RoomViewController.m | 85 +++++++- ...AttachmentWithPaginationTitleBubbleCell.h} | 10 +- ...gAttachmentWithPaginationTitleBubbleCell.m | 21 ++ ...ttachmentWithPaginationTitleBubbleCell.xib | 201 ++++++++++++++++++ .../RoomIncomingBubbleTableViewCell.m | 116 ---------- ...ingTextMsgWithPaginationTitleBubbleCell.h} | 7 +- ...mingTextMsgWithPaginationTitleBubbleCell.m | 21 ++ ...ngTextMsgWithPaginationTitleBubbleCell.xib | 148 +++++++++++++ .../RoomOutgoingAttachmentBubbleCell.h | 24 +++ .../RoomOutgoingAttachmentBubbleCell.m | 31 +++ ...b => RoomOutgoingAttachmentBubbleCell.xib} | 122 +++++------ ...OutgoingAttachmentHiddenSenderBubbleCell.h | 24 +++ ...OutgoingAttachmentHiddenSenderBubbleCell.m | 21 ++ ...tgoingAttachmentHiddenSenderBubbleCell.xib | 141 ++++++++++++ ...gAttachmentWithPaginationTitleBubbleCell.h | 27 +++ ...gAttachmentWithPaginationTitleBubbleCell.m | 31 +++ ...tachmentWithPaginationTitleBubbleCell.xib} | 144 +++++++------ .../RoomOutgoingBubbleTableViewCell.m | 125 ----------- .../RoomOutgoingTextMsgBubbleCell.h | 24 +++ .../RoomOutgoingTextMsgBubbleCell.m | 21 ++ .../RoomOutgoingTextMsgBubbleCell.xib | 107 ++++++++++ ...oomOutgoingTextMsgHiddenSenderBubbleCell.h | 24 +++ ...oomOutgoingTextMsgHiddenSenderBubbleCell.m | 21 ++ ...mOutgoingTextMsgHiddenSenderBubbleCell.xib | 80 +++++++ ...oingTextMsgWithPaginationTitleBubbleCell.h | 27 +++ ...oingTextMsgWithPaginationTitleBubbleCell.m | 31 +++ ...ngTextMsgWithPaginationTitleBubbleCell.xib | 135 ++++++++++++ 29 files changed, 1460 insertions(+), 552 deletions(-) rename Vector/Views/RoomBubbleList/{RoomOutgoingBubbleTableViewCell.h => RoomIncomingAttachmentWithPaginationTitleBubbleCell.h} (65%) create mode 100644 Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.m create mode 100644 Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib delete mode 100644 Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.m rename Vector/Views/RoomBubbleList/{RoomIncomingBubbleTableViewCell.h => RoomIncomingTextMsgWithPaginationTitleBubbleCell.h} (72%) create mode 100644 Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.m create mode 100644 Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.h create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m rename Vector/Views/RoomBubbleList/{RoomIncomingBubbleTableViewCell.xib => RoomOutgoingAttachmentBubbleCell.xib} (67%) create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.h create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.m create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.xib create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m rename Vector/Views/RoomBubbleList/{RoomOutgoingBubbleTableViewCell.xib => RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib} (67%) delete mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.m create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.h create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.xib create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.h create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.m create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.xib create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m create mode 100644 Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib diff --git a/Vector.xcodeproj/project.pbxproj b/Vector.xcodeproj/project.pbxproj index f19f121bf..c478c72ff 100644 --- a/Vector.xcodeproj/project.pbxproj +++ b/Vector.xcodeproj/project.pbxproj @@ -22,10 +22,6 @@ 71C5F2951C074ACC004C094B /* RoomSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 71C5F2941C074ACC004C094B /* RoomSettingsViewController.m */; }; 71EBE66D1C04C4D300E7D953 /* RoomActivitiesView.m in Sources */ = {isa = PBXBuildFile; fileRef = 71EBE66B1C04C4D300E7D953 /* RoomActivitiesView.m */; }; 71EBE66E1C04C4D300E7D953 /* RoomActivitiesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 71EBE66C1C04C4D300E7D953 /* RoomActivitiesView.xib */; }; - F001D75E1B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F001D7551B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.m */; }; - F001D75F1B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F001D7561B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.xib */; }; - F001D7601B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F001D7581B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.m */; }; - F001D7611B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F001D7591B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.xib */; }; F001D7621B8207C000A162C3 /* RoomInputToolbarView.m in Sources */ = {isa = PBXBuildFile; fileRef = F001D75C1B8207C000A162C3 /* RoomInputToolbarView.m */; }; F001D7631B8207C000A162C3 /* RoomInputToolbarView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F001D75D1B8207C000A162C3 /* RoomInputToolbarView.xib */; }; F001D76C1B821E4F00A162C3 /* MediaPickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F001D76B1B821E4F00A162C3 /* MediaPickerViewController.m */; }; @@ -117,6 +113,22 @@ F094AA371B78E42600B1FBBF /* RoomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F094AA271B78E42600B1FBBF /* RoomViewController.m */; }; F094AA381B78E42600B1FBBF /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F094AA291B78E42600B1FBBF /* SettingsViewController.m */; }; F0A1CD221B9F4BBA00F9C15C /* RoomParticipantsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0A1CD211B9F4BBA00F9C15C /* RoomParticipantsViewController.m */; }; + F0C34B611C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B561C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m */; }; + F0C34B621C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B571C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib */; }; + F0C34B631C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m */; }; + F0C34B641C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib */; }; + F0C34B651C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B5C1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m */; }; + F0C34B661C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B5D1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib */; }; + F0C34B671C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m */; }; + F0C34B681C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib */; }; + F0C34B6F1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B6A1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m */; }; + F0C34B701C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B6B1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib */; }; + F0C34B711C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B6D1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m */; }; + F0C34B721C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B6E1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib */; }; + F0C34CB11C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34CAC1C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.m */; }; + F0C34CB21C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34CAD1C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib */; }; + F0C34CB31C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34CAF1C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.m */; }; + F0C34CB41C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34CB01C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib */; }; F0DD7D821B7B363300C4BE02 /* RoomCreationStep1ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0DD7D811B7B363300C4BE02 /* RoomCreationStep1ViewController.m */; }; F0DD7D881B7B507100C4BE02 /* RoomCreationStep2ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0DD7D871B7B507100C4BE02 /* RoomCreationStep2ViewController.m */; }; /* End PBXBuildFile section */ @@ -160,12 +172,6 @@ 71EBE66B1C04C4D300E7D953 /* RoomActivitiesView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RoomActivitiesView.m; path = RoomActivitiesView/RoomActivitiesView.m; sourceTree = ""; }; 71EBE66C1C04C4D300E7D953 /* RoomActivitiesView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = RoomActivitiesView.xib; path = RoomActivitiesView/RoomActivitiesView.xib; sourceTree = ""; }; 9B179239B79688A61A3F465F /* libPods-Vector.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Vector.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - F001D7541B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomIncomingBubbleTableViewCell.h; sourceTree = ""; }; - F001D7551B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomIncomingBubbleTableViewCell.m; sourceTree = ""; }; - F001D7561B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomIncomingBubbleTableViewCell.xib; sourceTree = ""; }; - F001D7571B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingBubbleTableViewCell.h; sourceTree = ""; }; - F001D7581B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingBubbleTableViewCell.m; sourceTree = ""; }; - F001D7591B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingBubbleTableViewCell.xib; sourceTree = ""; }; F001D75B1B8207C000A162C3 /* RoomInputToolbarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomInputToolbarView.h; sourceTree = ""; }; F001D75C1B8207C000A162C3 /* RoomInputToolbarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomInputToolbarView.m; sourceTree = ""; }; F001D75D1B8207C000A162C3 /* RoomInputToolbarView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomInputToolbarView.xib; sourceTree = ""; }; @@ -277,6 +283,30 @@ F094AA291B78E42600B1FBBF /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; F0A1CD201B9F4BBA00F9C15C /* RoomParticipantsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomParticipantsViewController.h; sourceTree = ""; }; F0A1CD211B9F4BBA00F9C15C /* RoomParticipantsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomParticipantsViewController.m; sourceTree = ""; }; + F0C34B551C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingAttachmentBubbleCell.h; sourceTree = ""; }; + F0C34B561C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingAttachmentBubbleCell.m; sourceTree = ""; }; + F0C34B571C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingAttachmentBubbleCell.xib; sourceTree = ""; }; + F0C34B581C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingAttachmentHiddenSenderBubbleCell.h; sourceTree = ""; }; + F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingAttachmentHiddenSenderBubbleCell.m; sourceTree = ""; }; + F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingAttachmentHiddenSenderBubbleCell.xib; sourceTree = ""; }; + F0C34B5B1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingTextMsgBubbleCell.h; sourceTree = ""; }; + F0C34B5C1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingTextMsgBubbleCell.m; sourceTree = ""; }; + F0C34B5D1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingTextMsgBubbleCell.xib; sourceTree = ""; }; + F0C34B5E1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingTextMsgHiddenSenderBubbleCell.h; sourceTree = ""; }; + F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingTextMsgHiddenSenderBubbleCell.m; sourceTree = ""; }; + F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingTextMsgHiddenSenderBubbleCell.xib; sourceTree = ""; }; + F0C34B691C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h; sourceTree = ""; }; + F0C34B6A1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m; sourceTree = ""; }; + F0C34B6B1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib; sourceTree = ""; }; + F0C34B6C1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h; sourceTree = ""; }; + F0C34B6D1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m; sourceTree = ""; }; + F0C34B6E1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib; sourceTree = ""; }; + F0C34CAB1C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomIncomingAttachmentWithPaginationTitleBubbleCell.h; sourceTree = ""; }; + F0C34CAC1C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomIncomingAttachmentWithPaginationTitleBubbleCell.m; sourceTree = ""; }; + F0C34CAD1C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib; sourceTree = ""; }; + F0C34CAE1C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomIncomingTextMsgWithPaginationTitleBubbleCell.h; sourceTree = ""; }; + F0C34CAF1C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomIncomingTextMsgWithPaginationTitleBubbleCell.m; sourceTree = ""; }; + F0C34CB01C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib; sourceTree = ""; }; F0DD7D801B7B363300C4BE02 /* RoomCreationStep1ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomCreationStep1ViewController.h; sourceTree = ""; }; F0DD7D811B7B363300C4BE02 /* RoomCreationStep1ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomCreationStep1ViewController.m; sourceTree = ""; }; F0DD7D861B7B507100C4BE02 /* RoomCreationStep2ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomCreationStep2ViewController.h; sourceTree = ""; }; @@ -381,12 +411,30 @@ F001D7531B8207C000A162C3 /* RoomBubbleList */ = { isa = PBXGroup; children = ( - F001D7541B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.h */, - F001D7551B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.m */, - F001D7561B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.xib */, - F001D7571B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.h */, - F001D7581B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.m */, - F001D7591B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.xib */, + F0C34CAB1C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.h */, + F0C34CAC1C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.m */, + F0C34CAD1C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib */, + F0C34CAE1C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.h */, + F0C34CAF1C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.m */, + F0C34CB01C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib */, + F0C34B551C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.h */, + F0C34B561C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m */, + F0C34B571C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib */, + F0C34B581C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.h */, + F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m */, + F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib */, + F0C34B691C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h */, + F0C34B6A1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m */, + F0C34B6B1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib */, + F0C34B5B1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.h */, + F0C34B5C1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m */, + F0C34B5D1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib */, + F0C34B5E1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.h */, + F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m */, + F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib */, + F0C34B6C1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h */, + F0C34B6D1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m */, + F0C34B6E1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib */, ); path = RoomBubbleList; sourceTree = ""; @@ -746,6 +794,7 @@ F02528E01C11B6FC00E1FE1B /* create_room.png in Resources */, F02528DF1C11B6FC00E1FE1B /* camera_video.png in Resources */, F02528E31C11B6FC00E1FE1B /* favorite_icon.png in Resources */, + F0C34B681C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib in Resources */, F02528F11C11B6FC00E1FE1B /* placeholder@3x.png in Resources */, F02528FB1C11B6FC00E1FE1B /* selection_tick@2x.png in Resources */, F02529081C11B6FC00E1FE1B /* unmute_icon@3x.png in Resources */, @@ -768,14 +817,16 @@ F02528D31C11B6FC00E1FE1B /* add.png in Resources */, F02529061C11B6FC00E1FE1B /* unmute_icon.png in Resources */, F02529041C11B6FC00E1FE1B /* typing@2x.png in Resources */, + F0C34B641C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib in Resources */, F02528D61C11B6FC00E1FE1B /* camera_capture@2x.png in Resources */, 71046D601C0C86C600DCA984 /* RoomTitleViewWithTopic.xib in Resources */, F02528D51C11B6FC00E1FE1B /* camera_capture.png in Resources */, F02528EA1C11B6FC00E1FE1B /* low_priority_icon@2x.png in Resources */, - F001D7611B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.xib in Resources */, F02528EE1C11B6FC00E1FE1B /* mute_icon@3x.png in Resources */, F02529071C11B6FC00E1FE1B /* unmute_icon@2x.png in Resources */, + F0C34B701C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib in Resources */, F025290D1C11B6FC00E1FE1B /* voice_call_icon@2x.png in Resources */, + F0C34CB21C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib in Resources */, F02528DC1C11B6FC00E1FE1B /* camera_switch.png in Resources */, F02528E81C11B6FC00E1FE1B /* logo@2x.png in Resources */, F02528E21C11B6FC00E1FE1B /* create_room@3x.png in Resources */, @@ -795,6 +846,7 @@ F02528FF1C11B6FC00E1FE1B /* selection_untick@3x.png in Resources */, 717928481C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.xib in Resources */, F02528F01C11B6FC00E1FE1B /* placeholder@2x.png in Resources */, + F0C34CB41C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib in Resources */, F02528E41C11B6FC00E1FE1B /* favorite_icon@2x.png in Resources */, F001D76E1B83156000A162C3 /* MediaPickerViewController.xib in Resources */, F02529031C11B6FC00E1FE1B /* typing.png in Resources */, @@ -804,16 +856,18 @@ F02528F31C11B6FC00E1FE1B /* remove_icon@2x.png in Resources */, F02528E61C11B6FC00E1FE1B /* icon_video.png in Resources */, F02528D71C11B6FC00E1FE1B /* camera_capture@3x.png in Resources */, - F001D75F1B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.xib in Resources */, F02528EF1C11B6FC00E1FE1B /* placeholder.png in Resources */, F094A9B41B78D8F000B1FBBF /* Main.storyboard in Resources */, F094A9B91B78D8F000B1FBBF /* LaunchScreen.xib in Resources */, + F0C34B621C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib in Resources */, F094A9B61B78D8F000B1FBBF /* Images.xcassets in Resources */, F094AA061B78E3D400B1FBBF /* Vector-Defaults.plist in Resources */, F00C47871BFF77C800DBABC9 /* RecentTableViewCell.xib in Resources */, F02528E51C11B6FC00E1FE1B /* favorite_icon@3x.png in Resources */, F02529051C11B6FC00E1FE1B /* typing@3x.png in Resources */, F02528E71C11B6FC00E1FE1B /* logo.png in Resources */, + F0C34B721C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib in Resources */, + F0C34B661C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib in Resources */, F094AA2C1B78E42600B1FBBF /* Vector.strings in Resources */, F02528D41C11B6FC00E1FE1B /* add@2x.png in Resources */, F02528FD1C11B6FC00E1FE1B /* selection_untick.png in Resources */, @@ -887,13 +941,16 @@ F094A9AB1B78D8F000B1FBBF /* AppDelegate.m in Sources */, 717928491C03852C00407D96 /* TableViewCellWithLabelAndTextField.m in Sources */, F094AA2F1B78E42600B1FBBF /* AccountDetailsViewController.m in Sources */, + F0C34B671C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m in Sources */, + F0C34B651C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m in Sources */, + F0C34B711C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m in Sources */, F094AA051B78E3D400B1FBBF /* empty.mm in Sources */, F0A1CD221B9F4BBA00F9C15C /* RoomParticipantsViewController.m in Sources */, F001D76C1B821E4F00A162C3 /* MediaPickerViewController.m in Sources */, F084DAAE1BB57BD100B4C530 /* AuthInputsEmailIdentityBasedView.m in Sources */, - F001D75E1B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.m in Sources */, 71352D591C10569F001D50B0 /* AvatarGenerator.m in Sources */, 717928471C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.m in Sources */, + F0C34B6F1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m in Sources */, 7165A25B1C05CD42003635D7 /* SegmentedViewController.m in Sources */, F094AA321B78E42600B1FBBF /* GlobalNotificationSettingsViewController.m in Sources */, F094A9A81B78D8F000B1FBBF /* main.m in Sources */, @@ -901,15 +958,18 @@ F0DD7D881B7B507100C4BE02 /* RoomCreationStep2ViewController.m in Sources */, 71352D651C10A265001D50B0 /* Contact.m in Sources */, F094AA2A1B78E42600B1FBBF /* RageShakeManager.m in Sources */, + F0C34CB11C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.m in Sources */, F094AA351B78E42600B1FBBF /* RecentsViewController.m in Sources */, F08BE09E1B87025B00C480FB /* EventFormatter.m in Sources */, F05895001B8B7E6600B73E85 /* RoomBubbleCellData.m in Sources */, + F0C34B611C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m in Sources */, 71C5F2951C074ACC004C094B /* RoomSettingsViewController.m in Sources */, F001D7621B8207C000A162C3 /* RoomInputToolbarView.m in Sources */, 71EBE66D1C04C4D300E7D953 /* RoomActivitiesView.m in Sources */, F08BE0A21B87064000C480FB /* RoomDataSource.m in Sources */, - F001D7601B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.m in Sources */, + F0C34CB31C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.m in Sources */, 71046D5E1C0C639300DCA984 /* RoomTitleViewWithTopic.m in Sources */, + F0C34B631C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m in Sources */, F094AA371B78E42600B1FBBF /* RoomViewController.m in Sources */, F00C478B1BFF854400DBABC9 /* RecentsDataSource.m in Sources */, 717928451C03852C00407D96 /* TableViewCellSeparator.m in Sources */, diff --git a/Vector/Model/Room/RoomBubbleCellData.m b/Vector/Model/Room/RoomBubbleCellData.m index 3c9315602..45628b9c3 100644 --- a/Vector/Model/Room/RoomBubbleCellData.m +++ b/Vector/Model/Room/RoomBubbleCellData.m @@ -30,152 +30,11 @@ if (self) { - // use the matrix style placeholder + // use the vector style placeholder self.senderAvatarPlaceholder = [AvatarGenerator generateRoomMemberAvatar:self.senderId displayName:self.senderDisplayName]; } return self; } -- (NSAttributedString*)attributedTextMessage -{ - if (!attributedTextMessage.length && bubbleComponents.count) - { - if (super.showBubbleDateTime == NO) - { - return super.attributedTextMessage; - } - else - { - // Create attributed string by adding each component timestamp - NSMutableAttributedString *currentAttributedTextMsg; - NSAttributedString *dateTimeAttributedStr; - NSDictionary *attributes; - if ([self.eventFormatter isKindOfClass:[EventFormatter class]]) - { - attributes = [(EventFormatter*)self.eventFormatter stringAttributesForEventTimestamp]; - } - - for (MXKRoomBubbleComponent* component in bubbleComponents) - { - if (!currentAttributedTextMsg) - { - currentAttributedTextMsg = [[NSMutableAttributedString alloc] initWithAttributedString:component.attributedTextMessage]; - } - else - { - // Append attributed text - [currentAttributedTextMsg appendAttributedString:[MXKRoomBubbleCellDataWithAppendingMode messageSeparator]]; - [currentAttributedTextMsg appendAttributedString:component.attributedTextMessage]; - } - - // Append component timestamp - NSString *dateTimeStr = [NSString stringWithFormat:@" %@", [self.eventFormatter dateStringFromDate:component.date withTime:YES]]; - if (attributes) - { - dateTimeAttributedStr = [[NSAttributedString alloc] initWithString:dateTimeStr attributes:attributes]; - } - else - { - dateTimeAttributedStr = [[NSAttributedString alloc] initWithString:dateTimeStr]; - } - [currentAttributedTextMsg appendAttributedString:dateTimeAttributedStr]; - } - - attributedTextMessage = currentAttributedTextMsg; - } - } - - return attributedTextMessage; -} - -- (void)setShowBubbleDateTime:(BOOL)showBubbleDateTime -{ - if (super.showBubbleDateTime != showBubbleDateTime) - { - super.showBubbleDateTime = showBubbleDateTime; - - // Attributed string must be rebuilt - self.attributedTextMessage = nil; - } -} - -#pragma mark - - -- (void)prepareBubbleComponentsPosition -{ - if (super.showBubbleDateTime == NO) - { - [super prepareBubbleComponentsPosition]; - } - else - { - // We will let super prepare only the first component position by disabling shouldUpdateComponentsPosition flag - BOOL savedShouldUpdateComponentsPosition = shouldUpdateComponentsPosition; - shouldUpdateComponentsPosition = NO; - - [super prepareBubbleComponentsPosition]; - - // Check whether the position of other components need to be refreshed - if (self.attachment || !savedShouldUpdateComponentsPosition || bubbleComponents.count < 2) - { - return; - } - - // Compute height of the first text component by considering displayed timestamp - NSAttributedString *dateTimeAttributedStr; - NSDictionary *attributes; - if ([self.eventFormatter isKindOfClass:[EventFormatter class]]) - { - attributes = [(EventFormatter*)self.eventFormatter stringAttributesForEventTimestamp]; - } - - MXKRoomBubbleComponent *component = [bubbleComponents firstObject]; - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:component.attributedTextMessage]; - // Append component timestamp - NSString *dateTimeStr = [NSString stringWithFormat:@" %@", [self.eventFormatter dateStringFromDate:component.date withTime:YES]]; - if (attributes) - { - dateTimeAttributedStr = [[NSAttributedString alloc] initWithString:dateTimeStr attributes:attributes]; - } - else - { - dateTimeAttributedStr = [[NSAttributedString alloc] initWithString:dateTimeStr]; - } - [attributedString appendAttributedString:dateTimeAttributedStr]; - - CGFloat componentHeight = [self rawTextHeight:attributedString]; - - // Set position for each other component - CGFloat positionY = component.position.y; - CGFloat cumulatedHeight = 0; - - for (NSUInteger index = 1; index < bubbleComponents.count; index++) - { - cumulatedHeight += componentHeight; - positionY += componentHeight; - - component = [bubbleComponents objectAtIndex:index]; - component.position = CGPointMake(0, positionY); - - // Compute height of the current component - [attributedString appendAttributedString:[MXKRoomBubbleCellDataWithAppendingMode messageSeparator]]; - [attributedString appendAttributedString:component.attributedTextMessage]; - - dateTimeStr = [NSString stringWithFormat:@" %@", [self.eventFormatter dateStringFromDate:component.date withTime:YES]]; - if (attributes) - { - dateTimeAttributedStr = [[NSAttributedString alloc] initWithString:dateTimeStr attributes:attributes]; - } - else - { - dateTimeAttributedStr = [[NSAttributedString alloc] initWithString:dateTimeStr]; - } - [attributedString appendAttributedString:dateTimeAttributedStr]; - - componentHeight = [self rawTextHeight:attributedString] - cumulatedHeight; - } - } -} - @end diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index 5f0544ef1..b98b55f83 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -30,8 +30,15 @@ #import "SegmentedViewController.h" #import "RoomSettingsViewController.h" -#import "RoomOutgoingBubbleTableViewCell.h" -#import "RoomIncomingBubbleTableViewCell.h" +#import "RoomIncomingTextMsgWithPaginationTitleBubbleCell.h" +#import "RoomIncomingAttachmentWithPaginationTitleBubbleCell.h" + +#import "RoomOutgoingAttachmentBubbleCell.h" +#import "RoomOutgoingAttachmentHiddenSenderBubbleCell.h" +#import "RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h" +#import "RoomOutgoingTextMsgBubbleCell.h" +#import "RoomOutgoingTextMsgHiddenSenderBubbleCell.h" +#import "RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h" #import "AvatarGenerator.h" @@ -58,8 +65,15 @@ [super viewDidLoad]; // Register first customized cell view classes used to render bubbles - [self.bubblesTableView registerClass:RoomOutgoingBubbleTableViewCell.class forCellReuseIdentifier:RoomOutgoingBubbleTableViewCell.defaultReuseIdentifier]; - [self.bubblesTableView registerClass:RoomIncomingBubbleTableViewCell.class forCellReuseIdentifier:RoomIncomingBubbleTableViewCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomIncomingTextMsgWithPaginationTitleBubbleCell.class forCellReuseIdentifier:RoomIncomingTextMsgWithPaginationTitleBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomIncomingAttachmentWithPaginationTitleBubbleCell.class forCellReuseIdentifier:RoomIncomingAttachmentWithPaginationTitleBubbleCell.defaultReuseIdentifier]; + + [self.bubblesTableView registerClass:RoomOutgoingAttachmentBubbleCell.class forCellReuseIdentifier:RoomOutgoingAttachmentBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomOutgoingAttachmentHiddenSenderBubbleCell.class forCellReuseIdentifier:RoomOutgoingAttachmentHiddenSenderBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomOutgoingAttachmentWithPaginationTitleBubbleCell.class forCellReuseIdentifier:RoomOutgoingAttachmentWithPaginationTitleBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomOutgoingTextMsgBubbleCell.class forCellReuseIdentifier:RoomOutgoingTextMsgBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomOutgoingTextMsgHiddenSenderBubbleCell.class forCellReuseIdentifier:RoomOutgoingTextMsgHiddenSenderBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomOutgoingTextMsgWithPaginationTitleBubbleCell.class forCellReuseIdentifier:RoomOutgoingTextMsgWithPaginationTitleBubbleCell.defaultReuseIdentifier]; // Set room title view [self setRoomTitleViewClass:RoomTitleViewWithTopic.class]; @@ -234,11 +248,70 @@ // Select the suitable table view cell class if (bubbleData.isIncoming) { - cellViewClass = RoomIncomingBubbleTableViewCell.class; + if (bubbleData.isAttachmentWithThumbnail) + { + if (bubbleData.isPaginationFirstBubble) + { + cellViewClass = RoomIncomingAttachmentWithPaginationTitleBubbleCell.class; + } + else if (bubbleData.shouldHideSenderInformation) + { + cellViewClass = MXKRoomIncomingAttachmentHiddenSenderBubbleCell.class; + } + else + { + cellViewClass = MXKRoomIncomingAttachmentBubbleCell.class; + } + } + else + { + if (bubbleData.isPaginationFirstBubble) + { + cellViewClass = RoomIncomingTextMsgWithPaginationTitleBubbleCell.class; + } + else if (bubbleData.shouldHideSenderInformation) + { + cellViewClass = MXKRoomIncomingTextMsgHiddenSenderBubbleCell.class; + } + else + { + cellViewClass = MXKRoomIncomingTextMsgBubbleCell.class; + } + } } else { - cellViewClass = RoomOutgoingBubbleTableViewCell.class; + // Handle here outgoing bubbles + if (bubbleData.isAttachmentWithThumbnail) + { + if (bubbleData.isPaginationFirstBubble) + { + cellViewClass = RoomOutgoingAttachmentWithPaginationTitleBubbleCell.class; + } + else if (bubbleData.shouldHideSenderInformation) + { + cellViewClass = RoomOutgoingAttachmentHiddenSenderBubbleCell.class; + } + else + { + cellViewClass = RoomOutgoingAttachmentBubbleCell.class; + } + } + else + { + if (bubbleData.isPaginationFirstBubble) + { + cellViewClass = RoomOutgoingTextMsgWithPaginationTitleBubbleCell.class; + } + else if (bubbleData.shouldHideSenderInformation) + { + cellViewClass = RoomOutgoingTextMsgHiddenSenderBubbleCell.class; + } + else + { + cellViewClass = RoomOutgoingTextMsgBubbleCell.class; + } + } } } diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.h b/Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.h similarity index 65% rename from Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.h rename to Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.h index 8b3c8344e..4844d96cd 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.h +++ b/Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.h @@ -14,18 +14,14 @@ limitations under the License. */ -#import +#import "MXKRoomIncomingAttachmentBubbleCell.h" /** - `RoomOutgoingBubbleTableViewCell` displays outgoing message bubbles. + `RoomIncomingAttachmentWithPaginationTitleBubbleCell` displays incoming attachment bubbles with sender's information and a pagination title. */ -@interface RoomOutgoingBubbleTableViewCell : MXKRoomOutgoingBubbleTableViewCell - -// FIXME GFO -@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator; +@interface RoomIncomingAttachmentWithPaginationTitleBubbleCell : MXKRoomIncomingAttachmentBubbleCell @property (weak, nonatomic) IBOutlet UIView *paginationTitleView; @property (weak, nonatomic) IBOutlet UILabel *paginationLabel; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint *paginationTitleViewHeightConstraint; @end diff --git a/Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.m b/Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.m new file mode 100644 index 000000000..479b542d5 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.m @@ -0,0 +1,21 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomIncomingAttachmentWithPaginationTitleBubbleCell.h" + +@implementation RoomIncomingAttachmentWithPaginationTitleBubbleCell + +@end diff --git a/Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib b/Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib new file mode 100644 index 000000000..445f2ba6e --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.m b/Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.m deleted file mode 100644 index f1c97390a..000000000 --- a/Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.m +++ /dev/null @@ -1,116 +0,0 @@ -/* - Copyright 2015 OpenMarket Ltd - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#import "RoomIncomingBubbleTableViewCell.h" - -@interface RoomIncomingBubbleTableViewCell () -{ - BOOL showBubbleDateTimeFlag; -} - -@end - -@implementation RoomIncomingBubbleTableViewCell - -- (void)awakeFromNib -{ - [super awakeFromNib]; -} - -- (void)dealloc -{ -// [self stopTypingIndicatorAnimating]; -} - -- (void)setAllTextHighlighted:(BOOL)allTextHighlighted -{ - if (allTextHighlighted) - { - // Hide timestamp during selection - self.bubbleData.showBubbleDateTime = NO; - } - else - { - // Restore the actual value of the showBubbleDateTime flag - self.bubbleData.showBubbleDateTime = showBubbleDateTimeFlag; - } - - super.allTextHighlighted = allTextHighlighted; -} - -- (void)render:(MXKCellData *)cellData -{ - [super render:cellData]; - - if (self.bubbleData) - { - showBubbleDateTimeFlag = self.bubbleData.showBubbleDateTime; - - // Check whether a new pagination start at this bubble - if (self.bubbleData.isPaginationFirstBubble) - { - self.paginationTitleViewHeightConstraint.constant = 20; - self.paginationLabel.text = [self.bubbleData.eventFormatter dateStringFromDate:self.bubbleData.date withTime:NO]; - } - else - { - self.paginationTitleViewHeightConstraint.constant = 0; - } - - // FIXME remove this temporary code - if (self.attachmentView && self.bubbleData.isAttachmentWithThumbnail) - { - self.attachmentView.hidden = NO; - self.messageTextView.hidden = YES; - } - else - { - self.attachmentView.hidden = YES; - self.messageTextView.hidden = NO; - } - - - // TODO handle here pagination display per day - - // TODO handle here typing indicator - } -} - -- (void)didEndDisplay -{ - [super didEndDisplay]; - - // Stop potential typing indicator -// [self stopTypingIndicatorAnimating]; -} - -+ (CGFloat)heightForCellData:(MXKCellData *)cellData withMaximumWidth:(CGFloat)maxWidth -{ - CGFloat rowHeight = [super heightForCellData:cellData withMaximumWidth:maxWidth]; - - MXKRoomBubbleCellData *bubbleData = (MXKRoomBubbleCellData*)cellData; - - // Check whether a new pagination start at this bubble - // The pagination label is displayed with the first bubble of the pagination - if (bubbleData.isPaginationFirstBubble) - { - rowHeight += 20; - } - - return rowHeight; -} - -@end diff --git a/Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.h b/Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.h similarity index 72% rename from Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.h rename to Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.h index 5904af1da..e30efa145 100644 --- a/Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.h +++ b/Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.h @@ -14,15 +14,14 @@ limitations under the License. */ -#import +#import "MXKRoomIncomingTextMsgBubbleCell.h" /** - `RoomIncomingBubbleTableViewCell` displays incoming message bubbles. + `RoomIncomingTextMsgWithPaginationTitleBubbleCell` displays incoming message bubbles with sender's information. */ -@interface RoomIncomingBubbleTableViewCell : MXKRoomIncomingBubbleTableViewCell +@interface RoomIncomingTextMsgWithPaginationTitleBubbleCell : MXKRoomIncomingTextMsgBubbleCell @property (weak, nonatomic) IBOutlet UIView *paginationTitleView; @property (weak, nonatomic) IBOutlet UILabel *paginationLabel; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint *paginationTitleViewHeightConstraint; @end diff --git a/Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.m b/Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.m new file mode 100644 index 000000000..d7f0cc9ba --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.m @@ -0,0 +1,21 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomIncomingTextMsgWithPaginationTitleBubbleCell.h" + +@implementation RoomIncomingTextMsgWithPaginationTitleBubbleCell + +@end diff --git a/Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib b/Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib new file mode 100644 index 000000000..c2eb30f90 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomIncomingTextMsgWithPaginationTitleBubbleCell.xib @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.h b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.h new file mode 100644 index 000000000..f28f564aa --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.h @@ -0,0 +1,24 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "MXKRoomOutgoingAttachmentBubbleCell.h" + +/** + `RoomOutgoingAttachmentBubbleCell` displays outgoing attachment bubbles. + */ +@interface RoomOutgoingAttachmentBubbleCell : MXKRoomOutgoingAttachmentBubbleCell + +@end diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m new file mode 100644 index 000000000..1abacf321 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m @@ -0,0 +1,31 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomOutgoingAttachmentBubbleCell.h" + +@implementation RoomOutgoingAttachmentBubbleCell + +- (void)render:(MXKCellData *)cellData +{ + [super render:cellData]; +} + +- (void)didEndDisplay +{ + [super didEndDisplay]; +} + +@end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.xib b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.xib similarity index 67% rename from Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.xib rename to Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.xib index 946366d53..d4469865a 100644 --- a/Vector/Views/RoomBubbleList/RoomIncomingBubbleTableViewCell.xib +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.xib @@ -7,34 +7,13 @@ - + - - - - - - - - - - - - - - - @@ -45,7 +24,7 @@ - - - - - - - - - - - - + + - - + + + + - - - - - - - - - + + + diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.h b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.h new file mode 100644 index 000000000..1fcb9a78d --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.h @@ -0,0 +1,24 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "MXKRoomOutgoingAttachmentHiddenSenderBubbleCell.h" + +/** + `RoomOutgoingAttachmentHiddenSenderBubbleCell` displays outgoing attachment with thumbnail, without user's name. + */ +@interface RoomOutgoingAttachmentHiddenSenderBubbleCell : MXKRoomOutgoingAttachmentHiddenSenderBubbleCell + +@end diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.m new file mode 100644 index 000000000..17aba48da --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.m @@ -0,0 +1,21 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomOutgoingAttachmentHiddenSenderBubbleCell.h" + +@implementation RoomOutgoingAttachmentHiddenSenderBubbleCell + +@end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.xib b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.xib new file mode 100644 index 000000000..b43adac2a --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.xib @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h new file mode 100644 index 000000000..0777a4140 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h @@ -0,0 +1,27 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomOutgoingAttachmentBubbleCell.h" + +/** + `RoomOutgoingAttachmentWithPaginationTitleBubbleCell` displays outgoing attachment bubbles and pagination title. + */ +@interface RoomOutgoingAttachmentWithPaginationTitleBubbleCell : RoomOutgoingAttachmentBubbleCell + +@property (weak, nonatomic) IBOutlet UIView *paginationTitleView; +@property (weak, nonatomic) IBOutlet UILabel *paginationLabel; + +@end diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m new file mode 100644 index 000000000..0cd9c6299 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m @@ -0,0 +1,31 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h" + +@implementation RoomOutgoingAttachmentWithPaginationTitleBubbleCell + +- (void)render:(MXKCellData *)cellData +{ + [super render:cellData]; + + if (self.bubbleData) + { + self.paginationLabel.text = [self.bubbleData.eventFormatter dateStringFromDate:self.bubbleData.date withTime:NO]; + } +} + +@end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.xib b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib similarity index 67% rename from Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.xib rename to Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib index 3c88add2a..a6b82e0cf 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.xib +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib @@ -3,22 +3,23 @@ + - - + + - + - - + + - - + @@ -45,7 +46,7 @@ - - - - - - - - - - - - - - - - - - + - - + - - - + + + + - - - - - - - - - + + + + + - + diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.m deleted file mode 100644 index 3b4f9b821..000000000 --- a/Vector/Views/RoomBubbleList/RoomOutgoingBubbleTableViewCell.m +++ /dev/null @@ -1,125 +0,0 @@ -/* - Copyright 2015 OpenMarket Ltd - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#import "RoomOutgoingBubbleTableViewCell.h" - -#pragma mark - UI Constant definitions -#define MXKROOMBUBBLETABLEVIEWCELL_OUTGOING_HEIGHT_REDUCTION_WHEN_SENDER_INFO_IS_HIDDEN -10 - -@interface RoomOutgoingBubbleTableViewCell () -{ - BOOL showBubbleDateTimeFlag; -} - -@end - -@implementation RoomOutgoingBubbleTableViewCell - -- (void)setAllTextHighlighted:(BOOL)allTextHighlighted -{ - if (allTextHighlighted) - { - // Hide timestamp during selection - self.bubbleData.showBubbleDateTime = NO; - } - else - { - // Restore the actual value of the showBubbleDateTime flag - self.bubbleData.showBubbleDateTime = showBubbleDateTimeFlag; - } - - super.allTextHighlighted = allTextHighlighted; -} - -- (void)render:(MXKCellData *)cellData -{ - [super render:cellData]; - - if (self.bubbleData) - { - showBubbleDateTimeFlag = self.bubbleData.showBubbleDateTime; - - // Check whether a new pagination start at this bubble - if (self.bubbleData.isPaginationFirstBubble) - { - self.paginationTitleViewHeightConstraint.constant = 20; - self.paginationLabel.text = [self.bubbleData.eventFormatter dateStringFromDate:self.bubbleData.date withTime:NO]; - } - else - { - self.paginationTitleViewHeightConstraint.constant = 0; - } - - // FIXME remove this temporary code - if (self.attachmentView && self.bubbleData.isAttachmentWithThumbnail) - { - self.attachmentView.hidden = NO; - self.messageTextView.hidden = YES; - } - else - { - self.attachmentView.hidden = YES; - self.messageTextView.hidden = NO; - } - - - // TODO handle here unsent - - // Add unsent label for failed components -// for (MXKRoomBubbleComponent *component in self.bubbleData.bubbleComponents) -// { -// if (component.event.mxkState == MXKEventStateSendingFailed) -// { -// UIButton *unsentButton = [[UIButton alloc] initWithFrame:CGRectMake(0, component.position.y, 58 , 20)]; -// -// [unsentButton setTitle:[NSBundle mxk_localizedStringForKey:@"unsent"] forState:UIControlStateNormal]; -// [unsentButton setTitle:[NSBundle mxk_localizedStringForKey:@"unsent"] forState:UIControlStateSelected]; -// [unsentButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; -// [unsentButton setTitleColor:[UIColor redColor] forState:UIControlStateSelected]; -// -// unsentButton.backgroundColor = [UIColor whiteColor]; -// unsentButton.titleLabel.font = [UIFont systemFontOfSize:14]; -// -// [unsentButton addTarget:self action:@selector(onResendToggle:) forControlEvents:UIControlEventTouchUpInside]; -// -// [self.dateTimeLabelContainer addSubview:unsentButton]; -// self.dateTimeLabelContainer.hidden = NO; -// self.dateTimeLabelContainer.userInteractionEnabled = YES; -// -// // ensure that dateTimeLabelContainer is at front to catch the tap event -// [self.dateTimeLabelContainer.superview bringSubviewToFront:self.dateTimeLabelContainer]; -// } -// } - } -} - -+ (CGFloat)heightForCellData:(MXKCellData *)cellData withMaximumWidth:(CGFloat)maxWidth -{ - CGFloat rowHeight = [super heightForCellData:cellData withMaximumWidth:maxWidth]; - - MXKRoomBubbleCellData *bubbleData = (MXKRoomBubbleCellData*)cellData; - - // Check whether a new pagination start at this bubble - // The pagination label is displayed with the first bubble of the pagination - if (bubbleData.isPaginationFirstBubble) - { - rowHeight += 20; - } - - return rowHeight; -} - -@end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.h b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.h new file mode 100644 index 000000000..ec09deecf --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.h @@ -0,0 +1,24 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "MXKRoomOutgoingTextMsgBubbleCell.h" + +/** + `RoomOutgoingTextMsgBubbleCell` displays outgoing message bubbles with user's picture. + */ +@interface RoomOutgoingTextMsgBubbleCell : MXKRoomOutgoingTextMsgBubbleCell + +@end diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m new file mode 100644 index 000000000..9cb6bd59a --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m @@ -0,0 +1,21 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomOutgoingTextMsgBubbleCell.h" + +@implementation RoomOutgoingTextMsgBubbleCell + +@end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.xib b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.xib new file mode 100644 index 000000000..04d93d135 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.xib @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.h b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.h new file mode 100644 index 000000000..c840111fb --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.h @@ -0,0 +1,24 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "MXKRoomOutgoingTextMsgHiddenSenderBubbleCell.h" + +/** + `RoomOutgoingTextMsgHiddenSenderBubbleCell` displays outgoing message bubbles without user's name. + */ +@interface RoomOutgoingTextMsgHiddenSenderBubbleCell : MXKRoomOutgoingTextMsgHiddenSenderBubbleCell + +@end diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.m new file mode 100644 index 000000000..f600da092 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.m @@ -0,0 +1,21 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomOutgoingTextMsgHiddenSenderBubbleCell.h" + +@implementation RoomOutgoingTextMsgHiddenSenderBubbleCell + +@end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.xib b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.xib new file mode 100644 index 000000000..6e8a4f47f --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.xib @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h new file mode 100644 index 000000000..75802d3de --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h @@ -0,0 +1,27 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomOutgoingTextMsgBubbleCell.h" + +/** + `RoomOutgoingTextMsgWithPaginationTitleBubbleCell` displays outgoing message bubbles with user's picture and pagination title. + */ +@interface RoomOutgoingTextMsgWithPaginationTitleBubbleCell : RoomOutgoingTextMsgBubbleCell + +@property (weak, nonatomic) IBOutlet UIView *paginationTitleView; +@property (weak, nonatomic) IBOutlet UILabel *paginationLabel; + +@end diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m new file mode 100644 index 000000000..507285c48 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m @@ -0,0 +1,31 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h" + +@implementation RoomOutgoingTextMsgWithPaginationTitleBubbleCell + +- (void)render:(MXKCellData *)cellData +{ + [super render:cellData]; + + if (self.bubbleData) + { + self.paginationLabel.text = [self.bubbleData.eventFormatter dateStringFromDate:self.bubbleData.date withTime:NO]; + } +} + +@end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib new file mode 100644 index 000000000..aa95b1e74 --- /dev/null +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From ebf58876f3944a579df1e487d78365202fcdc418 Mon Sep 17 00:00:00 2001 From: giomfo Date: Tue, 8 Dec 2015 10:54:48 +0100 Subject: [PATCH 05/13] Chat screen: rename cell view classes --- Vector.xcodeproj/project.pbxproj | 40 +++++++++---------- Vector/ViewController/RoomViewController.m | 16 ++++---- ...ngAttachmentWithoutSenderInfoBubbleCell.h} | 6 +-- ...ngAttachmentWithoutSenderInfoBubbleCell.m} | 4 +- ...AttachmentWithoutSenderInfoBubbleCell.xib} | 3 +- ...goingTextMsgWithoutSenderInfoBubbleCell.h} | 6 +-- ...goingTextMsgWithoutSenderInfoBubbleCell.m} | 4 +- ...ingTextMsgWithoutSenderInfoBubbleCell.xib} | 3 +- 8 files changed, 40 insertions(+), 42 deletions(-) rename Vector/Views/RoomBubbleList/{RoomOutgoingAttachmentHiddenSenderBubbleCell.h => RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h} (66%) rename Vector/Views/RoomBubbleList/{RoomOutgoingTextMsgHiddenSenderBubbleCell.m => RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m} (81%) rename Vector/Views/RoomBubbleList/{RoomOutgoingAttachmentHiddenSenderBubbleCell.xib => RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib} (99%) rename Vector/Views/RoomBubbleList/{RoomOutgoingTextMsgHiddenSenderBubbleCell.h => RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h} (67%) rename Vector/Views/RoomBubbleList/{RoomOutgoingAttachmentHiddenSenderBubbleCell.m => RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m} (82%) rename Vector/Views/RoomBubbleList/{RoomOutgoingTextMsgHiddenSenderBubbleCell.xib => RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib} (98%) diff --git a/Vector.xcodeproj/project.pbxproj b/Vector.xcodeproj/project.pbxproj index c478c72ff..6a038ecf0 100644 --- a/Vector.xcodeproj/project.pbxproj +++ b/Vector.xcodeproj/project.pbxproj @@ -115,12 +115,12 @@ F0A1CD221B9F4BBA00F9C15C /* RoomParticipantsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0A1CD211B9F4BBA00F9C15C /* RoomParticipantsViewController.m */; }; F0C34B611C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B561C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m */; }; F0C34B621C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B571C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib */; }; - F0C34B631C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m */; }; - F0C34B641C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib */; }; + F0C34B631C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m */; }; + F0C34B641C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib */; }; F0C34B651C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B5C1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m */; }; F0C34B661C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B5D1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib */; }; - F0C34B671C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m */; }; - F0C34B681C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib */; }; + F0C34B671C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m */; }; + F0C34B681C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib */; }; F0C34B6F1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B6A1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m */; }; F0C34B701C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0C34B6B1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib */; }; F0C34B711C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C34B6D1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m */; }; @@ -286,15 +286,15 @@ F0C34B551C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingAttachmentBubbleCell.h; sourceTree = ""; }; F0C34B561C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingAttachmentBubbleCell.m; sourceTree = ""; }; F0C34B571C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingAttachmentBubbleCell.xib; sourceTree = ""; }; - F0C34B581C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingAttachmentHiddenSenderBubbleCell.h; sourceTree = ""; }; - F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingAttachmentHiddenSenderBubbleCell.m; sourceTree = ""; }; - F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingAttachmentHiddenSenderBubbleCell.xib; sourceTree = ""; }; + F0C34B581C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h; sourceTree = ""; }; + F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m; sourceTree = ""; }; + F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib; sourceTree = ""; }; F0C34B5B1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingTextMsgBubbleCell.h; sourceTree = ""; }; F0C34B5C1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingTextMsgBubbleCell.m; sourceTree = ""; }; F0C34B5D1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingTextMsgBubbleCell.xib; sourceTree = ""; }; - F0C34B5E1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingTextMsgHiddenSenderBubbleCell.h; sourceTree = ""; }; - F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingTextMsgHiddenSenderBubbleCell.m; sourceTree = ""; }; - F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingTextMsgHiddenSenderBubbleCell.xib; sourceTree = ""; }; + F0C34B5E1C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h; sourceTree = ""; }; + F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m; sourceTree = ""; }; + F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib; sourceTree = ""; }; F0C34B691C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h; sourceTree = ""; }; F0C34B6A1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m; sourceTree = ""; }; F0C34B6B1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib; sourceTree = ""; }; @@ -420,18 +420,18 @@ F0C34B551C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.h */, F0C34B561C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.m */, F0C34B571C15C28300C36F09 /* RoomOutgoingAttachmentBubbleCell.xib */, - F0C34B581C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.h */, - F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m */, - F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib */, + F0C34B581C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h */, + F0C34B591C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m */, + F0C34B5A1C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib */, F0C34B691C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h */, F0C34B6A1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m */, F0C34B6B1C15CA2E00C36F09 /* RoomOutgoingAttachmentWithPaginationTitleBubbleCell.xib */, F0C34B5B1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.h */, F0C34B5C1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m */, F0C34B5D1C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.xib */, - F0C34B5E1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.h */, - F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m */, - F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib */, + F0C34B5E1C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h */, + F0C34B5F1C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m */, + F0C34B601C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib */, F0C34B6C1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h */, F0C34B6D1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m */, F0C34B6E1C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.xib */, @@ -794,7 +794,7 @@ F02528E01C11B6FC00E1FE1B /* create_room.png in Resources */, F02528DF1C11B6FC00E1FE1B /* camera_video.png in Resources */, F02528E31C11B6FC00E1FE1B /* favorite_icon.png in Resources */, - F0C34B681C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.xib in Resources */, + F0C34B681C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib in Resources */, F02528F11C11B6FC00E1FE1B /* placeholder@3x.png in Resources */, F02528FB1C11B6FC00E1FE1B /* selection_tick@2x.png in Resources */, F02529081C11B6FC00E1FE1B /* unmute_icon@3x.png in Resources */, @@ -817,7 +817,7 @@ F02528D31C11B6FC00E1FE1B /* add.png in Resources */, F02529061C11B6FC00E1FE1B /* unmute_icon.png in Resources */, F02529041C11B6FC00E1FE1B /* typing@2x.png in Resources */, - F0C34B641C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.xib in Resources */, + F0C34B641C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib in Resources */, F02528D61C11B6FC00E1FE1B /* camera_capture@2x.png in Resources */, 71046D601C0C86C600DCA984 /* RoomTitleViewWithTopic.xib in Resources */, F02528D51C11B6FC00E1FE1B /* camera_capture.png in Resources */, @@ -941,7 +941,7 @@ F094A9AB1B78D8F000B1FBBF /* AppDelegate.m in Sources */, 717928491C03852C00407D96 /* TableViewCellWithLabelAndTextField.m in Sources */, F094AA2F1B78E42600B1FBBF /* AccountDetailsViewController.m in Sources */, - F0C34B671C15C28300C36F09 /* RoomOutgoingTextMsgHiddenSenderBubbleCell.m in Sources */, + F0C34B671C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m in Sources */, F0C34B651C15C28300C36F09 /* RoomOutgoingTextMsgBubbleCell.m in Sources */, F0C34B711C15CA2E00C36F09 /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m in Sources */, F094AA051B78E3D400B1FBBF /* empty.mm in Sources */, @@ -969,7 +969,7 @@ F08BE0A21B87064000C480FB /* RoomDataSource.m in Sources */, F0C34CB31C16269D00C36F09 /* RoomIncomingTextMsgWithPaginationTitleBubbleCell.m in Sources */, 71046D5E1C0C639300DCA984 /* RoomTitleViewWithTopic.m in Sources */, - F0C34B631C15C28300C36F09 /* RoomOutgoingAttachmentHiddenSenderBubbleCell.m in Sources */, + F0C34B631C15C28300C36F09 /* RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m in Sources */, F094AA371B78E42600B1FBBF /* RoomViewController.m in Sources */, F00C478B1BFF854400DBABC9 /* RecentsDataSource.m in Sources */, 717928451C03852C00407D96 /* TableViewCellSeparator.m in Sources */, diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index b98b55f83..ad2c5eab4 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -34,10 +34,10 @@ #import "RoomIncomingAttachmentWithPaginationTitleBubbleCell.h" #import "RoomOutgoingAttachmentBubbleCell.h" -#import "RoomOutgoingAttachmentHiddenSenderBubbleCell.h" +#import "RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h" #import "RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h" #import "RoomOutgoingTextMsgBubbleCell.h" -#import "RoomOutgoingTextMsgHiddenSenderBubbleCell.h" +#import "RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h" #import "RoomOutgoingTextMsgWithPaginationTitleBubbleCell.h" #import "AvatarGenerator.h" @@ -69,10 +69,10 @@ [self.bubblesTableView registerClass:RoomIncomingAttachmentWithPaginationTitleBubbleCell.class forCellReuseIdentifier:RoomIncomingAttachmentWithPaginationTitleBubbleCell.defaultReuseIdentifier]; [self.bubblesTableView registerClass:RoomOutgoingAttachmentBubbleCell.class forCellReuseIdentifier:RoomOutgoingAttachmentBubbleCell.defaultReuseIdentifier]; - [self.bubblesTableView registerClass:RoomOutgoingAttachmentHiddenSenderBubbleCell.class forCellReuseIdentifier:RoomOutgoingAttachmentHiddenSenderBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.defaultReuseIdentifier]; [self.bubblesTableView registerClass:RoomOutgoingAttachmentWithPaginationTitleBubbleCell.class forCellReuseIdentifier:RoomOutgoingAttachmentWithPaginationTitleBubbleCell.defaultReuseIdentifier]; [self.bubblesTableView registerClass:RoomOutgoingTextMsgBubbleCell.class forCellReuseIdentifier:RoomOutgoingTextMsgBubbleCell.defaultReuseIdentifier]; - [self.bubblesTableView registerClass:RoomOutgoingTextMsgHiddenSenderBubbleCell.class forCellReuseIdentifier:RoomOutgoingTextMsgHiddenSenderBubbleCell.defaultReuseIdentifier]; + [self.bubblesTableView registerClass:RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.defaultReuseIdentifier]; [self.bubblesTableView registerClass:RoomOutgoingTextMsgWithPaginationTitleBubbleCell.class forCellReuseIdentifier:RoomOutgoingTextMsgWithPaginationTitleBubbleCell.defaultReuseIdentifier]; // Set room title view @@ -256,7 +256,7 @@ } else if (bubbleData.shouldHideSenderInformation) { - cellViewClass = MXKRoomIncomingAttachmentHiddenSenderBubbleCell.class; + cellViewClass = MXKRoomIncomingAttachmentWithoutSenderInfoBubbleCell.class; } else { @@ -271,7 +271,7 @@ } else if (bubbleData.shouldHideSenderInformation) { - cellViewClass = MXKRoomIncomingTextMsgHiddenSenderBubbleCell.class; + cellViewClass = MXKRoomIncomingTextMsgWithoutSenderInfoBubbleCell.class; } else { @@ -290,7 +290,7 @@ } else if (bubbleData.shouldHideSenderInformation) { - cellViewClass = RoomOutgoingAttachmentHiddenSenderBubbleCell.class; + cellViewClass = RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.class; } else { @@ -305,7 +305,7 @@ } else if (bubbleData.shouldHideSenderInformation) { - cellViewClass = RoomOutgoingTextMsgHiddenSenderBubbleCell.class; + cellViewClass = RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.class; } else { diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.h b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h similarity index 66% rename from Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.h rename to Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h index 1fcb9a78d..980318e59 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.h +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h @@ -14,11 +14,11 @@ limitations under the License. */ -#import "MXKRoomOutgoingAttachmentHiddenSenderBubbleCell.h" +#import "MXKRoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h" /** - `RoomOutgoingAttachmentHiddenSenderBubbleCell` displays outgoing attachment with thumbnail, without user's name. + `RoomOutgoingAttachmentWithoutSenderInfoBubbleCell` displays outgoing attachment with thumbnail, without user's name. */ -@interface RoomOutgoingAttachmentHiddenSenderBubbleCell : MXKRoomOutgoingAttachmentHiddenSenderBubbleCell +@interface RoomOutgoingAttachmentWithoutSenderInfoBubbleCell : MXKRoomOutgoingAttachmentWithoutSenderInfoBubbleCell @end diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m similarity index 81% rename from Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.m rename to Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m index f600da092..f1bccf327 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.m +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m @@ -14,8 +14,8 @@ limitations under the License. */ -#import "RoomOutgoingTextMsgHiddenSenderBubbleCell.h" +#import "RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h" -@implementation RoomOutgoingTextMsgHiddenSenderBubbleCell +@implementation RoomOutgoingAttachmentWithoutSenderInfoBubbleCell @end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.xib b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib similarity index 99% rename from Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.xib rename to Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib index b43adac2a..951122e86 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.xib +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.xib @@ -1,13 +1,12 @@ - - + diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.h b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h similarity index 67% rename from Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.h rename to Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h index c840111fb..b063e069d 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.h +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h @@ -14,11 +14,11 @@ limitations under the License. */ -#import "MXKRoomOutgoingTextMsgHiddenSenderBubbleCell.h" +#import "MXKRoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h" /** - `RoomOutgoingTextMsgHiddenSenderBubbleCell` displays outgoing message bubbles without user's name. + `RoomOutgoingTextMsgWithoutSenderInfoBubbleCell` displays outgoing message bubbles without user's name. */ -@interface RoomOutgoingTextMsgHiddenSenderBubbleCell : MXKRoomOutgoingTextMsgHiddenSenderBubbleCell +@interface RoomOutgoingTextMsgWithoutSenderInfoBubbleCell : MXKRoomOutgoingTextMsgWithoutSenderInfoBubbleCell @end diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m similarity index 82% rename from Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.m rename to Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m index 17aba48da..07fea8672 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentHiddenSenderBubbleCell.m +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m @@ -14,8 +14,8 @@ limitations under the License. */ -#import "RoomOutgoingAttachmentHiddenSenderBubbleCell.h" +#import "RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.h" -@implementation RoomOutgoingAttachmentHiddenSenderBubbleCell +@implementation RoomOutgoingTextMsgWithoutSenderInfoBubbleCell @end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.xib b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib similarity index 98% rename from Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.xib rename to Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib index 6e8a4f47f..db1cc9042 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgHiddenSenderBubbleCell.xib +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.xib @@ -1,13 +1,12 @@ - - + From 5340584a8f44fc181850ef7e3757f7d03cd9bd0e Mon Sep 17 00:00:00 2001 From: yannick Date: Tue, 8 Dec 2015 15:39:53 +0100 Subject: [PATCH 06/13] user_settings_page -> add password update dialog. (it works only on IOS 8 and above). --- Vector/Assets/en.lproj/Vector.strings | 8 + .../ViewController/SettingsViewController.m | 142 ++++++++++++++++-- 2 files changed, 138 insertions(+), 12 deletions(-) diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index ab3f4fe5c..3568dde07 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -31,6 +31,7 @@ "on" = "On"; "off" = "Off"; "cancel" = "Cancel"; +"save" = "Save"; // Authentication "auth_sign_in" = "Sign in"; @@ -117,6 +118,13 @@ "settings_privacy_policy" = "Privacy Policy"; "settings_clear_cache" = "Clear cache"; +"settings_change_password" = "Change password"; +"settings_old_password" = "old password"; +"settings_new_password" = "new password"; +"settings_confirm_password" = "confirm password"; +"settings_fail_to_update_password" = "Fail to update password"; +"settings_password_updated" = "Your password has been updated"; + // Room Details "room_details_title" = "Room Details"; "room_details_room_name" = "Room Name"; diff --git a/Vector/ViewController/SettingsViewController.m b/Vector/ViewController/SettingsViewController.m index 3ebcf7267..4c6a66adc 100644 --- a/Vector/ViewController/SettingsViewController.m +++ b/Vector/ViewController/SettingsViewController.m @@ -80,8 +80,14 @@ // the avatar image has been uploaded NSString* uploadedAvatarURL; - // new displaynamed + // new display name NSString* newDisplayName; + + // password update + UITextField* currentPasswordTextField; + UITextField* newPasswordTextField1; + UITextField* newPasswordTextField2; + UIAlertAction* savePasswordAction; } @end @@ -498,6 +504,7 @@ MXKTableViewCellWithLabelAndTextField *passwordCell = [self getLabelAndTextFieldCell:tableView]; passwordCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_change_password", @"Vector", nil); + passwordCell.mxkTextField.text = @"*********"; passwordCell.mxkTextField.userInteractionEnabled = NO; cell = passwordCell; @@ -737,6 +744,10 @@ [self presentViewController:navigationController animated:YES completion:nil]; } + else if (row == USER_SETTINGS_CHANGE_PASSWORD_INDEX) + { + [self displayPasswordAlert]; + } } if ([firstResponder isFirstResponder]) @@ -763,6 +774,12 @@ - (void)onRuleUpdate:(id)sender { + // sanity check + if ([MXKAccountManager sharedManager].activeAccounts.count == 0) + { + return; + } + MXPushRule* pushRule = nil; MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; @@ -807,10 +824,17 @@ // - (void)onSave:(id)sender { + // sanity check + if ([MXKAccountManager sharedManager].activeAccounts.count == 0) + { + return; + } + [self startActivityIndicator]; - + MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; MXMyUser* myUser = account.mxSession.myUser; + if (newDisplayName && ![myUser.displayname isEqualToString:newDisplayName]) { // Save display name @@ -903,20 +927,23 @@ - (void)updateSaveButtonStatus { - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; - MXMyUser* myUser = session.myUser; - - BOOL saveButtonEnabled = (nil != newAvatarImage); - - if (!saveButtonEnabled) + if ([AppDelegate theDelegate].mxSessions.count > 0) { - if (newDisplayName) + MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXMyUser* myUser = session.myUser; + + BOOL saveButtonEnabled = (nil != newAvatarImage); + + if (!saveButtonEnabled) { - saveButtonEnabled = ![myUser.displayname isEqualToString:newDisplayName]; + if (newDisplayName) + { + saveButtonEnabled = ![myUser.displayname isEqualToString:newDisplayName]; + } } + + self.navigationItem.rightBarButtonItem.enabled = saveButtonEnabled; } - - self.navigationItem.rightBarButtonItem.enabled = saveButtonEnabled; } #pragma mark - MediaPickerViewController Delegate @@ -968,4 +995,95 @@ firstResponder = (UIView*)sender; } +#pragma password update management + +- (IBAction)passwordTextFieldDidChange:(id)sender +{ + savePasswordAction.enabled = (currentPasswordTextField.text.length > 0) && (newPasswordTextField1.text.length > 2) && [newPasswordTextField1.text isEqualToString:newPasswordTextField2.text]; +} + +- (void)displayPasswordAlert +{ + UIAlertController * alert = [UIAlertController + alertControllerWithTitle:NSLocalizedStringFromTable(@"settings_change_password", @"Vector", nil) + message:nil + preferredStyle:UIAlertControllerStyleAlert]; + + savePasswordAction = [UIAlertAction + actionWithTitle:NSLocalizedStringFromTable(@"save", @"Vector", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) + { + if ([MXKAccountManager sharedManager].activeAccounts.count > 0) + { + [self startActivityIndicator]; + + MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; + [account changePassword:currentPasswordTextField.text with:newPasswordTextField1.text success:^{ + + [self stopActivityIndicator]; + + [[[UIAlertView alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"settings_password_updated", @"Vector", nil) delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"ok", @"Vector", nil) otherButtonTitles:nil] show]; + + } failure:^(NSError *error) { + + [self stopActivityIndicator]; + + [[[UIAlertView alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"settings_fail_to_update_password", @"Vector", nil) delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"ok", @"Vector", nil) otherButtonTitles:nil] show]; + + }]; + } + else + { + [alert dismissViewControllerAnimated:YES completion:nil]; + } + + }]; + + // disable by default + // check if the textfields have the right value + savePasswordAction.enabled = NO; + + UIAlertAction* cancel = [UIAlertAction + actionWithTitle:@"Cancel" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) + { + [alert dismissViewControllerAnimated:YES completion:nil]; + }]; + [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) + { + currentPasswordTextField = textField; + currentPasswordTextField.placeholder = NSLocalizedStringFromTable(@"settings_old_password", @"Vector", nil); + currentPasswordTextField.secureTextEntry = YES; + [currentPasswordTextField addTarget:self action:@selector(passwordTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; + + }]; + + [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) + { + newPasswordTextField1 = textField; + newPasswordTextField1.placeholder = NSLocalizedStringFromTable(@"settings_new_password", @"Vector", nil); + newPasswordTextField1.secureTextEntry = YES; + [newPasswordTextField1 addTarget:self action:@selector(passwordTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; + + }]; + + [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) + { + newPasswordTextField2 = textField; + newPasswordTextField2.placeholder = NSLocalizedStringFromTable(@"settings_confirm_password", @"Vector", nil); + newPasswordTextField2.secureTextEntry = YES; + [newPasswordTextField2 addTarget:self action:@selector(passwordTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; + + newPasswordTextField2 = textField; + }]; + + + [alert addAction:cancel]; + [alert addAction:savePasswordAction]; + + [self presentViewController:alert animated:YES completion:nil]; +} + @end From da7b8bd88ab77aedb141025ed5645827ccd5472f Mon Sep 17 00:00:00 2001 From: yannick Date: Tue, 8 Dec 2015 15:52:54 +0100 Subject: [PATCH 07/13] user_settings_page push rules Make the difference between my user name and my display name rules. --- .../ViewController/SettingsViewController.m | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Vector/ViewController/SettingsViewController.m b/Vector/ViewController/SettingsViewController.m index 4c6a66adc..7856b9318 100644 --- a/Vector/ViewController/SettingsViewController.m +++ b/Vector/ViewController/SettingsViewController.m @@ -42,13 +42,14 @@ #define USER_SETTINGS_NIGHT_MODE_INDEX 8 #define USER_SETTINGS_COUNT 9 -#define NOTIFICATION_SETTINGS_ENABLE_ALL_INDEX 0 -#define NOTIFICATION_SETTINGS_CONTAINING_MY_NAME_INDEX 1 -#define NOTIFICATION_SETTINGS_SENT_TO_ME_INDEX 2 -#define NOTIFICATION_SETTINGS_INVITED_TO_ROOM_INDEX 3 -#define NOTIFICATION_SETTINGS_PEOPLE_LEAVE_JOIN_INDEX 4 -#define NOTIFICATION_SETTINGS_CALL_INVITATION_INDEX 5 -#define NOTIFICATION_SETTINGS_COUNT 6 +#define NOTIFICATION_SETTINGS_ENABLE_ALL_INDEX 0 +#define NOTIFICATION_SETTINGS_CONTAINING_MY_USER_NAME_INDEX 1 +#define NOTIFICATION_SETTINGS_CONTAINING_MY_DISPLAY_NAME_INDEX 2 +#define NOTIFICATION_SETTINGS_SENT_TO_ME_INDEX 3 +#define NOTIFICATION_SETTINGS_INVITED_TO_ROOM_INDEX 4 +#define NOTIFICATION_SETTINGS_PEOPLE_LEAVE_JOIN_INDEX 5 +#define NOTIFICATION_SETTINGS_CALL_INVITATION_INDEX 6 +#define NOTIFICATION_SETTINGS_COUNT 7 #define OTHER_VERSION_INDEX 0 #define OTHER_TERM_CONDITIONS_INDEX 1 @@ -550,11 +551,19 @@ cell = enableAllCell; } - else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_NAME_INDEX) + else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_USER_NAME_INDEX) { MXKTableViewCellWithLabelAndSwitch* myNameCell = [self getLabelAndSwitchCell:tableView]; - myNameCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_messages_my_name", @"Vector", nil); + myNameCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_messages_my_user_name", @"Vector", nil); + rule = [session.notificationCenter ruleById:kMXNotificationCenterContainUserNameRuleID]; + cell = myNameCell; + } + else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_DISPLAY_NAME_INDEX) + { + MXKTableViewCellWithLabelAndSwitch* myNameCell = [self getLabelAndSwitchCell:tableView]; + + myNameCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_messages_my_display_name", @"Vector", nil); rule = [session.notificationCenter ruleById:kMXNotificationCenterContainDisplayNameRuleID]; cell = myNameCell; } @@ -793,10 +802,14 @@ // toggle the pushes [account setEnablePushNotifications:!account.pushNotificationServiceIsActive]; } - else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_NAME_INDEX) + else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_DISPLAY_NAME_INDEX) { pushRule = [session.notificationCenter ruleById:kMXNotificationCenterContainDisplayNameRuleID]; } + else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_USER_NAME_INDEX) + { + pushRule = [session.notificationCenter ruleById:kMXNotificationCenterContainUserNameRuleID]; + } else if (row == NOTIFICATION_SETTINGS_SENT_TO_ME_INDEX) { pushRule = [session.notificationCenter ruleById:kMXNotificationCenterOneToOneRoomRuleID]; From 7fba0003c7b432dfab444b092766e9f3e5b63b14 Mon Sep 17 00:00:00 2001 From: yannick Date: Tue, 8 Dec 2015 15:53:12 +0100 Subject: [PATCH 08/13] Fix some texts --- Vector/Assets/en.lproj/Vector.strings | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 3568dde07..38e386798 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -107,7 +107,8 @@ "settings_enable_all_notif" = "Enable all notifications"; "settings_general_messages" = "General messages"; -"settings_messages_my_name" = "Messages containing my name"; +"settings_messages_my_display_name" = "Msg containing my display name"; +"settings_messages_my_user_name" = "Msg containing my user name"; "settings_messages_sent_to_me" = "Messages sent to me"; "settings_invited_to_room" = "When i'm invited to a room"; "settings_join_leave_rooms" = "When people join or leave rooms"; From 49b9266582b7b84f8ae291c85db8a3fbd74e9134 Mon Sep 17 00:00:00 2001 From: yannick Date: Tue, 8 Dec 2015 16:37:52 +0100 Subject: [PATCH 09/13] Add a comment. --- Vector/ViewController/SettingsViewController.m | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Vector/ViewController/SettingsViewController.m b/Vector/ViewController/SettingsViewController.m index 7856b9318..fbbc1d4f1 100644 --- a/Vector/ViewController/SettingsViewController.m +++ b/Vector/ViewController/SettingsViewController.m @@ -287,12 +287,13 @@ // Keep ref on destinationViewController [super prepareForSegue:segue sender:sender]; - if ([[segue identifier] isEqualToString:@"showAccountDetails"]) + // FIX ME add night mode + /*if ([[segue identifier] isEqualToString:@"showAccountDetails"]) { - //MXKAccountDetailsViewController *accountViewController = segue.destinationViewController; - //accountViewController.mxAccount = selectedAccount; - //selectedAccount = nil; - } + MXKAccountDetailsViewController *accountViewController = segue.destinationViewController; + accountViewController.mxAccount = selectedAccount; + selectedAccount = nil; + }*/ } #pragma mark - UIScrollView delegate @@ -662,7 +663,7 @@ cell = clearCacheBtnCell; } } - + return cell; } From 948a58405a3e48df4a0dbdefba7b46fd9ac5dd82 Mon Sep 17 00:00:00 2001 From: yannick Date: Tue, 8 Dec 2015 16:51:49 +0100 Subject: [PATCH 10/13] user_settings_page Hide some unsupported account settings --- Vector/ViewController/SettingsViewController.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Vector/ViewController/SettingsViewController.m b/Vector/ViewController/SettingsViewController.m index fbbc1d4f1..0d282f7ad 100644 --- a/Vector/ViewController/SettingsViewController.m +++ b/Vector/ViewController/SettingsViewController.m @@ -30,7 +30,7 @@ #define SETTINGS_SECTION_OTHER_INDEX 3 #define SETTINGS_SECTION_COUNT 4 - +/* #define USER_SETTINGS_PROFILE_PICTURE_INDEX 0 #define USER_SETTINGS_DISPLAY_NAME_INDEX 1 #define USER_SETTINGS_FIRST_NAME_INDEX 2 @@ -41,6 +41,20 @@ #define USER_SETTINGS_NIGHT_MODE_SEP_INDEX 7 #define USER_SETTINGS_NIGHT_MODE_INDEX 8 #define USER_SETTINGS_COUNT 9 + */ + +#define USER_SETTINGS_PROFILE_PICTURE_INDEX 0 +#define USER_SETTINGS_DISPLAY_NAME_INDEX 1 +#define USER_SETTINGS_CHANGE_PASSWORD_INDEX 2 +#define USER_SETTINGS_COUNT 3 + +// hide some unsupported account settings. +#define USER_SETTINGS_PHONE_NUMBER_INDEX -1 +#define USER_SETTINGS_NIGHT_MODE_SEP_INDEX -1 +#define USER_SETTINGS_NIGHT_MODE_INDEX -1 +#define USER_SETTINGS_FIRST_NAME_INDEX -1 +#define USER_SETTINGS_SURNAME_INDEX -1 +#define USER_SETTINGS_EMAIL_ADDRESS_INDEX -1 #define NOTIFICATION_SETTINGS_ENABLE_ALL_INDEX 0 #define NOTIFICATION_SETTINGS_CONTAINING_MY_USER_NAME_INDEX 1 From 9da0bdc9d08e9add43eb2f910c1288c4ef0d6b70 Mon Sep 17 00:00:00 2001 From: yannick Date: Tue, 8 Dec 2015 17:37:59 +0100 Subject: [PATCH 11/13] user_settings_page update after reviewing. --- .../ViewController/SettingsViewController.m | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/Vector/ViewController/SettingsViewController.m b/Vector/ViewController/SettingsViewController.m index 0d282f7ad..000ff9210 100644 --- a/Vector/ViewController/SettingsViewController.m +++ b/Vector/ViewController/SettingsViewController.m @@ -301,13 +301,7 @@ // Keep ref on destinationViewController [super prepareForSegue:segue sender:sender]; - // FIX ME add night mode - /*if ([[segue identifier] isEqualToString:@"showAccountDetails"]) - { - MXKAccountDetailsViewController *accountViewController = segue.destinationViewController; - accountViewController.mxAccount = selectedAccount; - selectedAccount = nil; - }*/ + // FIXME add night mode } #pragma mark - UIScrollView delegate @@ -743,15 +737,21 @@ { if (row == OTHER_TERM_CONDITIONS_INDEX) { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) otherButtonTitles:nil, nil]; - [alertView setMessage:NSLocalizedStringFromTable(@"settings_term_conditions", @"Vector", nil)]; - [alertView show]; - } + MXKAlert *alert = [[MXKAlert alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"settings_term_conditions", @"Vector", nil) style:MXKAlertStyleAlert]; + + alert.cancelButtonIndex = [alert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + }]; + + [alert showInViewController:self]; + } else if (row == OTHER_PRIVACY_INDEX) { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) otherButtonTitles:nil, nil]; - [alertView setMessage:NSLocalizedStringFromTable(@"settings_privacy_policy", @"Vector", nil)]; - [alertView show]; + MXKAlert *alert = [[MXKAlert alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"settings_privacy_policy", @"Vector", nil) style:MXKAlertStyleAlert]; + + alert.cancelButtonIndex = [alert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + }]; + + [alert showInViewController:self]; } } else if (section == SETTINGS_SECTION_USER_SETTINGS_INDEX) @@ -1051,14 +1051,23 @@ [self stopActivityIndicator]; - [[[UIAlertView alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"settings_password_updated", @"Vector", nil) delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"ok", @"Vector", nil) otherButtonTitles:nil] show]; - + MXKAlert *alert = [[MXKAlert alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"settings_password_updated", @"Vector", nil) style:MXKAlertStyleAlert]; + + alert.cancelButtonIndex = [alert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + }]; + + [alert showInViewController:self]; + } failure:^(NSError *error) { [self stopActivityIndicator]; - [[[UIAlertView alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"settings_fail_to_update_password", @"Vector", nil) delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"ok", @"Vector", nil) otherButtonTitles:nil] show]; + MXKAlert *alert = [[MXKAlert alloc] initWithTitle:nil message:NSLocalizedStringFromTable(@"settings_fail_to_update_password", @"Vector", nil) style:MXKAlertStyleAlert]; + alert.cancelButtonIndex = [alert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + }]; + + [alert showInViewController:self]; }]; } else From a111f44d7d56d1fccd4b72aeb397793251a39b8b Mon Sep 17 00:00:00 2001 From: yannick Date: Tue, 8 Dec 2015 17:44:55 +0100 Subject: [PATCH 12/13] Fix a crash in refreshTypingView --- Vector/ViewController/RoomViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index ad2c5eab4..782deb277 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -495,15 +495,15 @@ } } - if (0 == count) + if (0 == names.count) { // something to do ? } - else if (1 == count) + else if (1 == names.count) { text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_one_user_is_typing", @"Vector", nil), [names objectAtIndex:0]]; } - else if (2 == count) + else if (2 == names.count) { text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_two_users_are_typing", @"Vector", nil), [names objectAtIndex:0], [names objectAtIndex:1]]; } From e39746369d79f93e6df129ce23575814f9b8f008 Mon Sep 17 00:00:00 2001 From: yannick Date: Wed, 9 Dec 2015 09:50:03 +0100 Subject: [PATCH 13/13] The read receipts are displayed for incoming messages. In vector applciation, the outgoing and the imcoming messages are displayed in the same screen side. --- .../Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m | 6 ++++++ .../RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m | 6 ++++++ .../RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m | 6 ++++++ Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m | 6 ++++++ .../RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m | 6 ++++++ .../RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m index 1abacf321..e817473a4 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentBubbleCell.m @@ -18,6 +18,12 @@ @implementation RoomOutgoingAttachmentBubbleCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.readReceiptsAlignment = ReadReceiptAlignmentRight; +} + - (void)render:(MXKCellData *)cellData { [super render:cellData]; diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m index 0cd9c6299..33ed8fbb5 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m @@ -18,6 +18,12 @@ @implementation RoomOutgoingAttachmentWithPaginationTitleBubbleCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.readReceiptsAlignment = ReadReceiptAlignmentRight; +} + - (void)render:(MXKCellData *)cellData { [super render:cellData]; diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m index f1bccf327..2ab112729 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m +++ b/Vector/Views/RoomBubbleList/RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.m @@ -18,4 +18,10 @@ @implementation RoomOutgoingAttachmentWithoutSenderInfoBubbleCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.readReceiptsAlignment = ReadReceiptAlignmentRight; +} + @end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m index 9cb6bd59a..8841a746a 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgBubbleCell.m @@ -18,4 +18,10 @@ @implementation RoomOutgoingTextMsgBubbleCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.readReceiptsAlignment = ReadReceiptAlignmentRight; +} + @end \ No newline at end of file diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m index 507285c48..9327ceafb 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m @@ -18,6 +18,12 @@ @implementation RoomOutgoingTextMsgWithPaginationTitleBubbleCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.readReceiptsAlignment = ReadReceiptAlignmentRight; +} + - (void)render:(MXKCellData *)cellData { [super render:cellData]; diff --git a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m index 07fea8672..cedb7a761 100644 --- a/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m +++ b/Vector/Views/RoomBubbleList/RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m @@ -18,4 +18,10 @@ @implementation RoomOutgoingTextMsgWithoutSenderInfoBubbleCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.readReceiptsAlignment = ReadReceiptAlignmentRight; +} + @end \ No newline at end of file