diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..1a8060b2c Binary files /dev/null and b/.DS_Store differ diff --git a/Podfile b/Podfile index fb8159df9..70073cd8e 100644 --- a/Podfile +++ b/Podfile @@ -13,14 +13,13 @@ target "Vector" do # The lastest release available on the CocoaPods repository #pod 'MatrixKit' -# The develop branch version -pod 'MatrixSDK', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' -pod 'MatrixKit', :git => 'https://github.com/matrix-org/matrix-ios-kit.git', :branch => 'develop' # The one used for developping both MatrixSDK and MatrixKit # Note that MatrixSDK must be cloned into a folder called matrix-ios-sdk next to the MatrixKit folder -#pod 'MatrixKit', :path => '../matrix-ios-kit/MatrixKit.podspec' -#pod 'MatrixSDK', :path => '../matrix-ios-sdk/MatrixSDK.podspec' +pod 'MatrixKit', :path => '../matrix-ios-kit/MatrixKit.podspec' +pod 'MatrixSDK', :path => '../matrix-ios-sdk/MatrixSDK.podspec' + + pod 'GBDeviceInfo', '~> 3.4.0' diff --git a/Podfile.lock b/Podfile.lock index 8aec04aa6..ae99afb43 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -24,7 +24,7 @@ PODS: - GBJailbreakDetection (~> 1.0) - GBJailbreakDetection (1.3.0) - HPGrowingTextView (1.1) - - libPhoneNumber-iOS (0.8.8) + - libPhoneNumber-iOS (0.8.10) - Mantle (2.0.5): - Mantle/extobjc (= 2.0.5) - Mantle/extobjc (2.0.5) @@ -38,33 +38,23 @@ PODS: DEPENDENCIES: - GBDeviceInfo (~> 3.4.0) - - MatrixKit (from `https://github.com/matrix-org/matrix-ios-kit.git`, branch `develop`) - - MatrixSDK (from `https://github.com/matrix-org/matrix-ios-sdk.git`, branch `develop`) + - MatrixKit (from `../matrix-ios-kit/MatrixKit.podspec`) + - MatrixSDK (from `../matrix-ios-sdk/MatrixSDK.podspec`) EXTERNAL SOURCES: MatrixKit: - :branch: develop - :git: https://github.com/matrix-org/matrix-ios-kit.git + :path: ../matrix-ios-kit/MatrixKit.podspec MatrixSDK: - :branch: develop - :git: https://github.com/matrix-org/matrix-ios-sdk.git - -CHECKOUT OPTIONS: - MatrixKit: - :commit: 83c5e18793fecb39b73928e148098aecf34dcf41 - :git: https://github.com/matrix-org/matrix-ios-kit.git - MatrixSDK: - :commit: e26869211892fafcc651fea9a48331c2ad9a22f5 - :git: https://github.com/matrix-org/matrix-ios-sdk.git + :path: ../matrix-ios-sdk/MatrixSDK.podspec SPEC CHECKSUMS: AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60 GBDeviceInfo: bab0f43d351b6f641a626cd7d21492abef1afe46 GBJailbreakDetection: a216773574b62dddb6c876ffdb52c54ac05e27e0 HPGrowingTextView: 88a716d97fb853bcb08a4a08e4727da17efc9b19 - libPhoneNumber-iOS: fe877b7c44c270a9da2082d3e2892d5316f6a2f9 + libPhoneNumber-iOS: 7bfd00f843fdcd82b5182b463e8eb3b27579f41d Mantle: 1912395033f601de5adc8ee91e48f46e4c7051ad MatrixKit: 7e201f0624d6627988ee97c7b636a6a2abb41196 MatrixSDK: 47a452d56248eae27bbb332b33280986c1f1a854 -COCOAPODS: 0.39.0 +COCOAPODS: 0.38.2 diff --git a/Vector.xcodeproj/project.pbxproj b/Vector.xcodeproj/project.pbxproj index e8d6e1bae..0c59507bb 100644 --- a/Vector.xcodeproj/project.pbxproj +++ b/Vector.xcodeproj/project.pbxproj @@ -7,6 +7,13 @@ objects = { /* Begin PBXBuildFile section */ + 7179283A1C03847E00407D96 /* RoomDetailsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 717928391C03847E00407D96 /* RoomDetailsViewController.m */; settings = {ASSET_TAGS = (); }; }; + 717928451C03852C00407D96 /* TableViewCellSeparator.m in Sources */ = {isa = PBXBuildFile; fileRef = 7179283D1C03852C00407D96 /* TableViewCellSeparator.m */; settings = {ASSET_TAGS = (); }; }; + 717928461C03852C00407D96 /* TableViewCellSeparator.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7179283E1C03852C00407D96 /* TableViewCellSeparator.xib */; settings = {ASSET_TAGS = (); }; }; + 717928471C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 717928401C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.m */; settings = {ASSET_TAGS = (); }; }; + 717928481C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 717928411C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.xib */; settings = {ASSET_TAGS = (); }; }; + 717928491C03852C00407D96 /* TableViewCellWithLabelAndTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 717928431C03852C00407D96 /* TableViewCellWithLabelAndTextField.m */; settings = {ASSET_TAGS = (); }; }; + 7179284A1C03852C00407D96 /* TableViewCellWithLabelAndTextField.xib in Resources */ = {isa = PBXBuildFile; fileRef = 717928441C03852C00407D96 /* TableViewCellWithLabelAndTextField.xib */; settings = {ASSET_TAGS = (); }; }; 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 */; }; @@ -98,6 +105,17 @@ /* Begin PBXFileReference section */ 11865E69C29698A4179E1F3F /* Pods-Vector.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vector.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Vector/Pods-Vector.debug.xcconfig"; sourceTree = ""; }; 435C7E1A9BC3DE28D526540F /* Pods-Vector.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vector.release.xcconfig"; path = "Pods/Target Support Files/Pods-Vector/Pods-Vector.release.xcconfig"; sourceTree = ""; }; + 717928381C03847E00407D96 /* RoomDetailsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomDetailsViewController.h; sourceTree = ""; }; + 717928391C03847E00407D96 /* RoomDetailsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomDetailsViewController.m; sourceTree = ""; }; + 7179283C1C03852C00407D96 /* TableViewCellSeparator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TableViewCellSeparator.h; path = TableViewCell/TableViewCellSeparator.h; sourceTree = ""; }; + 7179283D1C03852C00407D96 /* TableViewCellSeparator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TableViewCellSeparator.m; path = TableViewCell/TableViewCellSeparator.m; sourceTree = ""; }; + 7179283E1C03852C00407D96 /* TableViewCellSeparator.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = TableViewCellSeparator.xib; path = TableViewCell/TableViewCellSeparator.xib; sourceTree = ""; }; + 7179283F1C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TableViewCellWithLabelAndLargeTextView.h; path = TableViewCell/TableViewCellWithLabelAndLargeTextView.h; sourceTree = ""; }; + 717928401C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TableViewCellWithLabelAndLargeTextView.m; path = TableViewCell/TableViewCellWithLabelAndLargeTextView.m; sourceTree = ""; }; + 717928411C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = TableViewCellWithLabelAndLargeTextView.xib; path = TableViewCell/TableViewCellWithLabelAndLargeTextView.xib; sourceTree = ""; }; + 717928421C03852C00407D96 /* TableViewCellWithLabelAndTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TableViewCellWithLabelAndTextField.h; path = TableViewCell/TableViewCellWithLabelAndTextField.h; sourceTree = ""; }; + 717928431C03852C00407D96 /* TableViewCellWithLabelAndTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TableViewCellWithLabelAndTextField.m; path = TableViewCell/TableViewCellWithLabelAndTextField.m; sourceTree = ""; }; + 717928441C03852C00407D96 /* TableViewCellWithLabelAndTextField.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = TableViewCellWithLabelAndTextField.xib; path = TableViewCell/TableViewCellWithLabelAndTextField.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 = ""; }; @@ -228,6 +246,22 @@ name = Frameworks; sourceTree = ""; }; + 7179283B1C0384DE00407D96 /* TableViewCell */ = { + isa = PBXGroup; + children = ( + 7179283C1C03852C00407D96 /* TableViewCellSeparator.h */, + 7179283D1C03852C00407D96 /* TableViewCellSeparator.m */, + 7179283E1C03852C00407D96 /* TableViewCellSeparator.xib */, + 7179283F1C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.h */, + 717928401C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.m */, + 717928411C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.xib */, + 717928421C03852C00407D96 /* TableViewCellWithLabelAndTextField.h */, + 717928431C03852C00407D96 /* TableViewCellWithLabelAndTextField.m */, + 717928441C03852C00407D96 /* TableViewCellWithLabelAndTextField.xib */, + ); + name = TableViewCell; + sourceTree = ""; + }; E1451F540F8BC02A7FB7AA31 /* Pods */ = { isa = PBXGroup; children = ( @@ -240,6 +274,7 @@ F001D7521B8207C000A162C3 /* Views */ = { isa = PBXGroup; children = ( + 7179283B1C0384DE00407D96 /* TableViewCell */, F00C47821BFF77C800DBABC9 /* RoomList */, F084DAAA1BB57BD100B4C530 /* Authentication */, F001D7531B8207C000A162C3 /* RoomBubbleList */, @@ -444,6 +479,8 @@ F0DD7D811B7B363300C4BE02 /* RoomCreationStep1ViewController.m */, F0DD7D861B7B507100C4BE02 /* RoomCreationStep2ViewController.h */, F0DD7D871B7B507100C4BE02 /* RoomCreationStep2ViewController.m */, + 717928381C03847E00407D96 /* RoomDetailsViewController.h */, + 717928391C03847E00407D96 /* RoomDetailsViewController.m */, F094AA261B78E42600B1FBBF /* RoomViewController.h */, F094AA271B78E42600B1FBBF /* RoomViewController.m */, F094AA281B78E42600B1FBBF /* SettingsViewController.h */, @@ -509,7 +546,6 @@ F094A99F1B78D8F000B1FBBF /* Frameworks */, F094A9A01B78D8F000B1FBBF /* Resources */, 44C35695CFA4F9799C449367 /* Copy Pods Resources */, - CE74DDBF8318D6A2441D715E /* Embed Pods Frameworks */, ); buildRules = ( ); @@ -588,6 +624,7 @@ F0316E3A1B7DF45A00F03620 /* add.png in Resources */, F0DD7D671B7AA8C900C4BE02 /* members@2x.png in Resources */, F001D7701B83243900A162C3 /* send_other.png in Resources */, + 7179284A1C03852C00407D96 /* TableViewCellWithLabelAndTextField.xib in Resources */, F00B1BCB1B95CC68001806E3 /* camera_record.png in Resources */, F001D7611B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.xib in Resources */, F094AA2E1B78E42600B1FBBF /* countryCodes.plist in Resources */, @@ -598,11 +635,13 @@ F0DD7D4C1B7AA8C900C4BE02 /* attach.png in Resources */, F00B1BD41B95D478001806E3 /* camera_video.png in Resources */, F00B1BDC1B96EF09001806E3 /* selection_tick.png in Resources */, + 717928481C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.xib in Resources */, F0316E3E1B7E28DE00F03620 /* remove.png in Resources */, F001D76E1B83156000A162C3 /* MediaPickerViewController.xib in Resources */, F0E956C01B834430004C1699 /* share_location.png in Resources */, F0316E3F1B7E28DE00F03620 /* remove@2x.png in Resources */, F0E956C31B834541004C1699 /* video_call.png in Resources */, + 717928461C03852C00407D96 /* TableViewCellSeparator.xib in Resources */, F0E956C61B834573004C1699 /* voice_call.png in Resources */, F0316E481B7E4C9A00F03620 /* placeholder@2x.png in Resources */, F001D75F1B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.xib in Resources */, @@ -674,21 +713,6 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - CE74DDBF8318D6A2441D715E /* Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Vector/Pods-Vector-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -698,12 +722,15 @@ files = ( F0DD7D821B7B363300C4BE02 /* RoomCreationStep1ViewController.m in Sources */, F094A9AB1B78D8F000B1FBBF /* AppDelegate.m in Sources */, + 717928491C03852C00407D96 /* TableViewCellWithLabelAndTextField.m in Sources */, F094AA2F1B78E42600B1FBBF /* AccountDetailsViewController.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 */, + 717928471C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.m in Sources */, + 7179283A1C03847E00407D96 /* RoomDetailsViewController.m in Sources */, F094AA321B78E42600B1FBBF /* GlobalNotificationSettingsViewController.m in Sources */, F094A9A81B78D8F000B1FBBF /* main.m in Sources */, F00C47861BFF77C800DBABC9 /* RecentTableViewCell.m in Sources */, @@ -717,6 +744,7 @@ F001D7601B8207C000A162C3 /* RoomOutgoingBubbleTableViewCell.m in Sources */, F094AA371B78E42600B1FBBF /* RoomViewController.m in Sources */, F00C478B1BFF854400DBABC9 /* RecentsDataSource.m in Sources */, + 717928451C03852C00407D96 /* TableViewCellSeparator.m in Sources */, F094AA381B78E42600B1FBBF /* SettingsViewController.m in Sources */, F094AA301B78E42600B1FBBF /* AuthenticationViewController.m in Sources */, ); diff --git a/Vector/.DS_Store b/Vector/.DS_Store new file mode 100644 index 000000000..52a129e2d Binary files /dev/null and b/Vector/.DS_Store differ diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 08e350564..4cc1785e7 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -85,6 +85,10 @@ "settings_title_config" = "Configuration"; "settings_clear_cache" = "Clear cache"; +// Room Details +"room_details_room_name" = "Room Name"; +"room_details_topic" = "Topic"; + "notification_settings_global_notification_settings" = "Global Notification Settings"; // Media picker diff --git a/Vector/Base.lproj/Main.storyboard b/Vector/Base.lproj/Main.storyboard index d3a69b5ce..c20487197 100644 --- a/Vector/Base.lproj/Main.storyboard +++ b/Vector/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -47,6 +47,7 @@ + @@ -255,7 +256,15 @@ - + + + + + + + + + @@ -467,7 +476,7 @@ + - diff --git a/Vector/ViewController/RoomDetailsViewController.h b/Vector/ViewController/RoomDetailsViewController.h new file mode 100644 index 000000000..1bfcbccf6 --- /dev/null +++ b/Vector/ViewController/RoomDetailsViewController.h @@ -0,0 +1,22 @@ +/* + Copyright 2014 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 + +@interface RoomDetailsViewController : MXKRoomDetailsViewController + +@end + diff --git a/Vector/ViewController/RoomDetailsViewController.m b/Vector/ViewController/RoomDetailsViewController.m new file mode 100644 index 000000000..41539064d --- /dev/null +++ b/Vector/ViewController/RoomDetailsViewController.m @@ -0,0 +1,412 @@ +/* + Copyright 2014 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 "RoomDetailsViewController.h" + +#import "TableViewCellWithLabelAndTextField.h" +#import "TableViewCellWithLabelAndLargeTextView.h" +#import "TableViewCellSeparator.h" + +#import "RageShakeManager.h" + +#define ROOM_SECTION 0 + +#define ROOM_SECTION_NAME 0 +#define ROOM_SECTION_TOPIC 1 +#define ROOM_SECTION_COUNT 2 + +#define ROOM_TOPIC_CELL_HEIGHT 99 + +@interface RoomDetailsViewController () +{ + // updated user data + NSMutableDictionary *updatedItems; + + // active items + UITextView* topicTextView; + UITextField* nameTextField; + + // pending http operation + MXHTTPOperation* pendingOperation; +} +@end + +@implementation RoomDetailsViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // TODO use a color panel + // not an hard coded one. + CGFloat item = (242.0f / 255.0); + + self.tableView.backgroundColor = [UIColor colorWithRed:item green:item blue:item alpha:item]; + self.tableView.separatorColor = [UIColor clearColor]; + + // Setup `RoomDetailsViewController` properties + self.rageShakeManager = [RageShakeManager sharedManager]; +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didMXSessionStateChange:) name:kMXSessionStateDidChangeNotification object:nil]; +} + +- (void)viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; + + [self dismissFirstResponder]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:kMXSessionStateDidChangeNotification object:nil]; +} + +- (void)destroy +{ + self.navigationItem.rightBarButtonItem.enabled = NO; + + if (pendingOperation) + { + [pendingOperation cancel]; + pendingOperation = nil; + } + + [super destroy]; +} + +#pragma mark - private + +- (NSMutableDictionary*)getUpdatedItems +{ + if (!updatedItems) + { + updatedItems = [[NSMutableDictionary alloc] init]; + } + + return updatedItems; +} + +- (void)dismissFirstResponder +{ + if ([topicTextView isFirstResponder]) + { + [topicTextView resignFirstResponder]; + } + + if ([nameTextField isFirstResponder]) + { + [nameTextField resignFirstResponder]; + } +} + +- (void)showUpdatingSpinner +{ + // TODO : wait that we have the final behaviour + self.view.alpha = 0.5f; + self.view.userInteractionEnabled = NO; +} + +- (void)hideUpdatingSpinner +{ + // TODO : wait that we have the final behaviour + self.view.alpha = 1.0f; + self.view.userInteractionEnabled = YES; +} + +#pragma mark - actions + +- (void)textViewDidChange:(UITextView *)textView +{ + // avoid nil pointer + NSString* text = (textView.text) ? textView.text : @""; + + if (topicTextView == textView) + { + [[self getUpdatedItems] setObject:text forKey:@"ROOM_SECTION_TOPIC"]; + } +} + +- (IBAction)onTextFieldUpdate:(UITextField*)textField +{ + // avoid nil pointer + NSString* text = (textField.text) ? textField.text : @""; + + if (nameTextField == textField) + { + [[self getUpdatedItems] setObject:text forKey:@"ROOM_SECTION_NAME"]; + } +} + +- (void)didMXSessionStateChange:(NSNotification *)notif +{ + // Check this is our Matrix session that has changed + if (notif.object == self.session) + { + // refresh when the session sync is done. + if (MXSessionStateRunning == self.session.state) + { + [self.tableView reloadData]; + } + } +} + +- (IBAction)onDone:(id)sender +{ + // check if there is some update + if (mxRoomState && updatedItems && (updatedItems.count > 0)) + { + // has a new room name + if ([updatedItems objectForKey:@"ROOM_SECTION_NAME"]) + { + NSString* newName = [updatedItems objectForKey:@"ROOM_SECTION_NAME"]; + + if (![newName isEqualToString:mxRoomState.name]) + { + [self showUpdatingSpinner]; + __weak typeof(self) weakSelf = self; + + pendingOperation = [mxRoom setName:newName success:^{ + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf->pendingOperation = nil; + [strongSelf->updatedItems removeObjectForKey:@"ROOM_SECTION_NAME"]; + [strongSelf onDone:nil]; + + } failure:^(NSError *error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + // TODO should stop the saving ? + // continue the saving by now + strongSelf->pendingOperation = nil; + [strongSelf->updatedItems removeObjectForKey:@"ROOM_SECTION_NAME"]; + [strongSelf onDone:nil]; + + NSLog(@"[onDone] Rename room failed: %@", error); + }]; + + return; + } + } + + // has a new room topic + if ([updatedItems objectForKey:@"ROOM_SECTION_TOPIC"]) + { + NSString* newTopic = [updatedItems objectForKey:@"ROOM_SECTION_TOPIC"]; + + if (![newTopic isEqualToString:mxRoomState.topic]) + { + [self showUpdatingSpinner]; + __weak typeof(self) weakSelf = self; + + pendingOperation = [mxRoom setTopic:newTopic success:^{ + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf->pendingOperation = nil; + [strongSelf->updatedItems removeObjectForKey:@"ROOM_SECTION_TOPIC"]; + [strongSelf onDone:nil]; + + } failure:^(NSError *error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + // TODO should stop the saving ? + // continue the saving by now + strongSelf->pendingOperation = nil; + [strongSelf->updatedItems removeObjectForKey:@"ROOM_SECTION_TOPIC"]; + [strongSelf onDone:nil]; + + NSLog(@"[onDone] Rename topic failed: %@", error); + }]; + + return; + } + } + } + + [self hideUpdatingSpinner]; + + [self.navigationController popViewControllerAnimated:YES]; +} + +#pragma mark - UITableViewDataSource + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + if (section == ROOM_SECTION) + { + // add separators + return ROOM_SECTION_COUNT * 2 + 1; + } + + return 0; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +{ + return 33.0f; +} + +- (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section +{ + UITableViewHeaderFooterView *header = [[UITableViewHeaderFooterView alloc] initWithFrame:CGRectMake(0, 0, 10, 33)]; + + header.backgroundColor = [UIColor redColor]; + + return header; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (indexPath.section == ROOM_SECTION) + { + NSInteger row = indexPath.row; + + // is a separator ? + if ((row % 2) == 0) + { + return 1.0f; + } + + // retrieve row as a ROOM_SECTION_XX index + row = (row - 1) / 2; + + if (row == ROOM_SECTION_TOPIC) + { + return ROOM_TOPIC_CELL_HEIGHT; + } + } + + return [super tableView:tableView heightForRowAtIndexPath:indexPath]; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + NSInteger row = indexPath.row; + UITableViewCell* cell = nil; + + // general settings + if (indexPath.section == ROOM_SECTION) + { + if ((row % 2) == 0) + { + UITableViewCell* sepCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellSeparator defaultReuseIdentifier]]; + + if (!sepCell) + { + sepCell = [[TableViewCellSeparator alloc] init]; + } + + // the borders are drawn in dark grey + sepCell.contentView.backgroundColor = ((row == 0) || (row == ROOM_SECTION_COUNT * 2)) ? [UIColor darkGrayColor] : [UIColor lightGrayColor]; + + return sepCell; + } + + // retrieve row as a ROOM_SECTION_XX index + row = (row - 1) / 2; + + if (row == ROOM_SECTION_TOPIC) + { + TableViewCellWithLabelAndLargeTextView *roomTopicCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellWithLabelAndLargeTextView defaultReuseIdentifier]]; + + if (!roomTopicCell) + { + roomTopicCell = [[TableViewCellWithLabelAndLargeTextView alloc] init]; + + // define the cell height + CGRect frame = roomTopicCell.frame; + frame.size.height = ROOM_TOPIC_CELL_HEIGHT; + roomTopicCell.frame = frame; + } + + roomTopicCell.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_topic", @"Vector", nil); + topicTextView = roomTopicCell.mxkTextView; + + if (updatedItems && [updatedItems objectForKey:@"ROOM_SECTION_TOPIC"]) + { + roomTopicCell.mxkTextView.text = (NSString*)[updatedItems objectForKey:@"ROOM_SECTION_TOPIC"]; + } + else + { + roomTopicCell.mxkTextView.text = mxRoomState.topic; + } + + roomTopicCell.mxkTextView.delegate = self; + + // disable the edition if the user cannoy update it + roomTopicCell.mxkTextView.editable = isSuperUser; + roomTopicCell.mxkTextView.textColor = isSuperUser ? [UIColor blackColor] : [UIColor lightGrayColor]; + + cell = roomTopicCell; + } + else if (row == ROOM_SECTION_NAME) + { + TableViewCellWithLabelAndTextField *roomNameCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellWithLabelAndTextField defaultReuseIdentifier]]; + + if (!roomNameCell) + { + roomNameCell = [[TableViewCellWithLabelAndTextField alloc] init]; + } + + roomNameCell.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_room_name", @"Vector", nil); + roomNameCell.mxkTextField.userInteractionEnabled = YES; + + if (updatedItems && [updatedItems objectForKey:@"ROOM_SECTION_NAME"]) + { + roomNameCell.mxkTextField.text = (NSString*)[updatedItems objectForKey:@"ROOM_SECTION_NAME"]; + } + else + { + roomNameCell.mxkTextField.text = mxRoomState.name; + } + roomNameCell.accessoryType = UITableViewCellAccessoryNone; + + cell = roomNameCell; + nameTextField = roomNameCell.mxkTextField; + + // disable the edition if the user cannoy update it + roomNameCell.editable = isSuperUser; + roomNameCell.mxkTextField.textColor = isSuperUser ? [UIColor blackColor] : [UIColor lightGrayColor]; + + + // Add a "textFieldDidChange" notification method to the text field control. + [roomNameCell.mxkTextField addTarget:self action:@selector(onTextFieldUpdate:) forControlEvents:UIControlEventEditingChanged]; + } + } + + return cell; +} + +- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (self.tableView == aTableView) + { + [self dismissFirstResponder]; + } +} + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + if (scrollView == self.tableView) + { + [self dismissFirstResponder]; + } +} + +@end + + diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index 8e9767d09..3eef35eeb 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -23,6 +23,8 @@ #import "RoomParticipantsViewController.h" +#import "RoomDetailsViewController.h" + @interface RoomViewController () { // The constraint used to animate menu list display @@ -301,6 +303,20 @@ participantsViewController.mxRoom = self.roomDataSource.room; } } + else if ([[segue identifier] isEqualToString:@"showRoomDetails"]) + { + if ([pushedViewController isKindOfClass:[RoomDetailsViewController class]]) + { + // Dismiss keyboard + [self dismissKeyboard]; + + RoomDetailsViewController* detailsViewController = (RoomDetailsViewController*)pushedViewController; + [detailsViewController initWithSession:self.roomDataSource.mxSession andRoomId:self.roomDataSource.roomId]; + } + } + + // Hide back button title + self.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; } #pragma mark - MXKRoomInputToolbarViewDelegate @@ -386,6 +402,20 @@ [super tableView:tableView didSelectRowAtIndexPath:indexPath]; } +#pragma mark - RoomDetailsViewController management + +- (BOOL)roomTitleViewShouldBeginEditing:(MXKRoomTitleView*)titleView +{ + // instead of opening a text edition + // launch a dedicated viewcontroller. + dispatch_async(dispatch_get_main_queue(), ^{ + [self performSegueWithIdentifier:@"showRoomDetails" sender:self]; + }); + + // cancel any requested edition + return NO; +} + @end diff --git a/Vector/Views/.DS_Store b/Vector/Views/.DS_Store new file mode 100644 index 000000000..e3af69ea9 Binary files /dev/null and b/Vector/Views/.DS_Store differ diff --git a/Vector/Views/TableViewCell/.DS_Store b/Vector/Views/TableViewCell/.DS_Store new file mode 100644 index 000000000..5008ddfcf Binary files /dev/null and b/Vector/Views/TableViewCell/.DS_Store differ diff --git a/Vector/Views/TableViewCell/TableViewCellSeparator.h b/Vector/Views/TableViewCell/TableViewCellSeparator.h new file mode 100644 index 000000000..cd27da69d --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellSeparator.h @@ -0,0 +1,22 @@ +/* + 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 "MXKTableViewCell.h" + +@interface TableViewCellSeparator : MXKTableViewCell + + +@end \ No newline at end of file diff --git a/Vector/Views/TableViewCell/TableViewCellSeparator.m b/Vector/Views/TableViewCell/TableViewCellSeparator.m new file mode 100644 index 000000000..6ff685117 --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellSeparator.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 "TableViewCellSeparator.h" + +@implementation TableViewCellSeparator + +@end diff --git a/Vector/Views/TableViewCell/TableViewCellSeparator.xib b/Vector/Views/TableViewCell/TableViewCellSeparator.xib new file mode 100644 index 000000000..153ad7110 --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellSeparator.xib @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.h b/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.h new file mode 100644 index 000000000..851c265a1 --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.h @@ -0,0 +1,26 @@ +/* + 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 "MXKTableViewCell.h" + +@interface TableViewCellWithLabelAndLargeTextView : MXKTableViewCell +{ +} + +@property (strong, nonatomic) IBOutlet UILabel *mxkLabel; +@property (strong, nonatomic) IBOutlet UITextView *mxkTextView; + +@end \ No newline at end of file diff --git a/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.m b/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.m new file mode 100644 index 000000000..b16626f6b --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.m @@ -0,0 +1,35 @@ +/* + 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 "TableViewCellWithLabelAndLargeTextView.h" + +@implementation TableViewCellWithLabelAndLargeTextView + +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) + { + } + + return self; +} + +- (void)dealloc +{ +} + +@end diff --git a/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.xib b/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.xib new file mode 100644 index 000000000..2aa0f1aca --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellWithLabelAndLargeTextView.xib @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.h b/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.h new file mode 100644 index 000000000..6c9ddaf29 --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.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 "MXKTableViewCellWithLabelAndTextField.h" + +@interface TableViewCellWithLabelAndTextField : MXKTableViewCellWithLabelAndTextField + +// YES to allow text edition +@property (nonatomic) BOOL editable; + +@end \ No newline at end of file diff --git a/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.m b/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.m new file mode 100644 index 000000000..a1c1037d1 --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.m @@ -0,0 +1,33 @@ +/* + 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 "TableViewCellWithLabelAndTextField.h" + +@implementation TableViewCellWithLabelAndTextField + +#pragma mark - UITextField delegate + +- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField +{ + if (textField == self.mxkTextField) + { + return _editable; + } + + return [super textFieldShouldBeginEditing:textField]; +} + +@end diff --git a/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.xib b/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.xib new file mode 100644 index 000000000..f8a90cf7f --- /dev/null +++ b/Vector/Views/TableViewCell/TableViewCellWithLabelAndTextField.xib @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +