Console: Update public room display (sorted by the number of members, display the number of members).

This commit is contained in:
giomfo 2015-02-23 17:44:58 +01:00
parent 879c323278
commit f897384ed5
5 changed files with 148 additions and 25 deletions

View file

@ -65,6 +65,7 @@
F07A80E919DD9DE700B621A1 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = F07A80E719DD9DE700B621A1 /* LaunchScreen.xib */; };
F07A80F519DD9DE700B621A1 /* matrixConsoleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F07A80F419DD9DE700B621A1 /* matrixConsoleTests.m */; };
F08B6FCC1A1DE7F80094A35B /* matrixConsole.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F08B6FCB1A1DE7F80094A35B /* matrixConsole.jpg */; };
F08DB7811A9B7C9300B73403 /* PublicRoomTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F08DB7801A9B7C9300B73403 /* PublicRoomTableCell.m */; };
F08DCBDB1A093BFA008C65B6 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F08DCBDA1A093BFA008C65B6 /* MobileCoreServices.framework */; };
F08E67961A77965A00AABD4C /* MXC3PID.m in Sources */ = {isa = PBXBuildFile; fileRef = F08E67931A77965A00AABD4C /* MXC3PID.m */; };
F0AC79331A8394510056D042 /* AuthInputsView.m in Sources */ = {isa = PBXBuildFile; fileRef = F0AC79321A8394510056D042 /* AuthInputsView.m */; };
@ -191,6 +192,8 @@
F07A80F319DD9DE700B621A1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F07A80F419DD9DE700B621A1 /* matrixConsoleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = matrixConsoleTests.m; sourceTree = "<group>"; };
F08B6FCB1A1DE7F80094A35B /* matrixConsole.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = matrixConsole.jpg; sourceTree = "<group>"; };
F08DB77F1A9B7C9300B73403 /* PublicRoomTableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicRoomTableCell.h; sourceTree = "<group>"; };
F08DB7801A9B7C9300B73403 /* PublicRoomTableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PublicRoomTableCell.m; sourceTree = "<group>"; };
F08DCBDA1A093BFA008C65B6 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
F08E67921A77965A00AABD4C /* MXC3PID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXC3PID.h; sourceTree = "<group>"; };
F08E67931A77965A00AABD4C /* MXC3PID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXC3PID.m; sourceTree = "<group>"; };
@ -351,6 +354,8 @@
F00B5DB81A1B9BCE00EA1C8D /* MXCImageView.m */,
71E94A751A5C4020009F52E5 /* PieChartView.h */,
71E94A761A5C4020009F52E5 /* PieChartView.m */,
F08DB77F1A9B7C9300B73403 /* PublicRoomTableCell.h */,
F08DB7801A9B7C9300B73403 /* PublicRoomTableCell.m */,
F0E84D3E1A1F9AEC005F2E42 /* RecentsTableViewCell.h */,
F0E84D3F1A1F9AEC005F2E42 /* RecentsTableViewCell.m */,
71D2E4EA1A49814B000DE015 /* RoomMemberActionsCell.h */,
@ -623,6 +628,7 @@
7176294F1A77FED800927125 /* ContactDetailsTableCell.m in Sources */,
F04A8AD81A3B3DF4008AC915 /* RoomTitleView.m in Sources */,
F07A80DB19DD9DE700B621A1 /* AppDelegate.m in Sources */,
F08DB7811A9B7C9300B73403 /* PublicRoomTableCell.m in Sources */,
F052377C1A7289F00079F3E0 /* APNSHandler.m in Sources */,
F03EF5FF19F1762000A0EE52 /* RoomMessageTableCell.m in Sources */,
F07A80D819DD9DE700B621A1 /* main.m in Sources */,

View file

@ -8,10 +8,10 @@
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--Recents-->
<!--RecentsNav-->
<scene sceneID="pY4-Hu-kfo">
<objects>
<navigationController title="Recents" id="RMx-3f-FxP" sceneMemberID="viewController">
<navigationController title="Recents" id="RMx-3f-FxP" userLabel="RecentsNav" sceneMemberID="viewController">
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="Pmd-2v-anx">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
@ -950,41 +950,82 @@
</constraints>
</view>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="PublicRoomCellBasic" textLabel="UoS-rO-98c" style="IBUITableViewCellStyleDefault" id="Y5I-fR-nF2">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="PublicRoomCell" id="Wz9-zE-cVU" userLabel="PublicRoomCell" customClass="PublicRoomTableCell">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Y5I-fR-nF2" id="k9k-ye-AWt">
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Wz9-zE-cVU" id="ao8-Y1-uLa">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="UoS-rO-98c">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="roomDisplayName" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RiU-Jb-mhv">
<rect key="frame" x="8" y="10" width="504" height="23"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="xx users" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VEa-DV-vyM">
<rect key="frame" x="520" y="13" width="72" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="centerY" secondItem="RiU-Jb-mhv" secondAttribute="centerY" id="6w2-nX-WXN"/>
<constraint firstItem="RiU-Jb-mhv" firstAttribute="leading" secondItem="ao8-Y1-uLa" secondAttribute="leading" constant="8" id="8fk-hh-48A"/>
<constraint firstAttribute="trailing" secondItem="VEa-DV-vyM" secondAttribute="trailing" constant="8" id="VLr-f1-8zn"/>
<constraint firstItem="VEa-DV-vyM" firstAttribute="leading" secondItem="RiU-Jb-mhv" secondAttribute="trailing" constant="8" id="dcM-g2-Mth"/>
<constraint firstAttribute="centerY" secondItem="VEa-DV-vyM" secondAttribute="centerY" id="raK-8e-0Jz"/>
<constraint firstAttribute="trailing" secondItem="RiU-Jb-mhv" secondAttribute="trailing" constant="88" id="ues-S3-d4I"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="memberCount" destination="VEa-DV-vyM" id="NZJ-Cp-GX2"/>
<outlet property="roomDisplayName" destination="RiU-Jb-mhv" id="beh-yS-hCG"/>
</connections>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="PublicRoomCellSubtitle" textLabel="XSB-xW-yiT" detailTextLabel="sfe-5d-fmq" style="IBUITableViewCellStyleSubtitle" id="ZA7-Uv-Ncb">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="PublicRoomWithTopicCell" rowHeight="60" id="ZA7-Uv-Ncb" userLabel="PublicRoomWithTopicCell" customClass="PublicRoomWithTopicTableCell">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ZA7-Uv-Ncb" id="N4f-z9-lYd">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="XSB-xW-yiT">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="roomDisplayName" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PTD-Ku-LXV">
<rect key="frame" x="8" y="8" width="504" height="23"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="sfe-5d-fmq">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="topic" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dqj-vC-3VV" userLabel="roomTopic">
<rect key="frame" x="8" y="31" width="584" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="xx users" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KWU-6k-Y5L">
<rect key="frame" x="520" y="11" width="72" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="KWU-6k-Y5L" secondAttribute="trailing" constant="8" id="4iQ-Hh-wc2"/>
<constraint firstAttribute="trailing" secondItem="PTD-Ku-LXV" secondAttribute="trailing" constant="88" id="8Kt-Bc-obY"/>
<constraint firstItem="KWU-6k-Y5L" firstAttribute="centerY" secondItem="PTD-Ku-LXV" secondAttribute="centerY" id="EEs-Uc-8Ua"/>
<constraint firstItem="dqj-vC-3VV" firstAttribute="leading" secondItem="N4f-z9-lYd" secondAttribute="leading" constant="8" id="FcQ-Ib-ich"/>
<constraint firstAttribute="bottom" secondItem="dqj-vC-3VV" secondAttribute="bottom" constant="8" id="Vsu-MF-gMy"/>
<constraint firstItem="PTD-Ku-LXV" firstAttribute="top" secondItem="N4f-z9-lYd" secondAttribute="top" constant="8" id="Yy9-nG-z1M"/>
<constraint firstItem="KWU-6k-Y5L" firstAttribute="leading" secondItem="PTD-Ku-LXV" secondAttribute="trailing" constant="8" id="bFb-p8-KBU"/>
<constraint firstItem="PTD-Ku-LXV" firstAttribute="leading" secondItem="N4f-z9-lYd" secondAttribute="leading" constant="8" id="lUQ-yM-Dh8"/>
<constraint firstAttribute="trailing" secondItem="dqj-vC-3VV" secondAttribute="trailing" constant="8" id="veq-Hf-j80"/>
<constraint firstItem="dqj-vC-3VV" firstAttribute="top" secondItem="PTD-Ku-LXV" secondAttribute="bottom" id="w2S-XG-rJ9"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="memberCount" destination="KWU-6k-Y5L" id="bVz-85-vVl"/>
<outlet property="roomDisplayName" destination="PTD-Ku-LXV" id="XeL-Mp-pDI"/>
<outlet property="roomTopic" destination="dqj-vC-3VV" id="3AC-Zy-b1N"/>
</connections>
</tableViewCell>
</prototypes>
<connections>

View file

@ -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 <UIKit/UIKit.h>
@interface PublicRoomTableCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *roomDisplayName;
@property (weak, nonatomic) IBOutlet UILabel *memberCount;
@end
@interface PublicRoomWithTopicTableCell : PublicRoomTableCell
@property (weak, nonatomic) IBOutlet UILabel *roomTopic;
@end

View file

@ -0,0 +1,23 @@
/*
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 "PublicRoomTableCell.h"
@implementation PublicRoomTableCell
@end
@implementation PublicRoomWithTopicTableCell
@end

View file

@ -18,6 +18,7 @@
#import "MatrixSDKHandler.h"
#import "AppDelegate.h"
#import "PublicRoomTableCell.h"
@interface HomeViewController () {
NSArray *publicRooms;
@ -69,7 +70,7 @@
// Init
publicRooms = nil;
highlightedPublicRooms = @[@"#matrix:matrix.org"]; // Add here a room name to highlight its display in public room list
highlightedPublicRooms = @[@"#matrix:matrix.org", @"#matrix-dev:matrix.org", @"#matrix-fr:matrix.org"]; // Add here a room name to highlight its display in public room list
}
- (void)didReceiveMemoryWarning {
@ -123,7 +124,15 @@
MXPublicRoom *firstRoom = (MXPublicRoom*)a;
MXPublicRoom *secondRoom = (MXPublicRoom*)b;
return [firstRoom.displayname compare:secondRoom.displayname options:NSCaseInsensitiveSearch];
// Compare member count
if (firstRoom.numJoinedMembers < secondRoom.numJoinedMembers) {
return NSOrderedDescending;
} else if (firstRoom.numJoinedMembers > secondRoom.numJoinedMembers) {
return NSOrderedAscending;
} else {
// Alphabetic order
return [firstRoom.displayname compare:secondRoom.displayname options:NSCaseInsensitiveSearch];
}
}];
[_publicRoomsTable reloadData];
}
@ -482,7 +491,9 @@
}
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
PublicRoomTableCell *cell;
PublicRoomWithTopicTableCell *cellWithTopic = nil;
MXPublicRoom *publicRoom;
if (filteredPublicRooms) {
publicRoom = [filteredPublicRooms objectAtIndex:indexPath.row];
@ -492,22 +503,38 @@
// Check whether this public room has topic
if (publicRoom.topic) {
cell = [_publicRoomsTable dequeueReusableCellWithIdentifier:@"PublicRoomCellSubtitle" forIndexPath:indexPath];
cell.detailTextLabel.text = publicRoom.topic;
cellWithTopic = [_publicRoomsTable dequeueReusableCellWithIdentifier:@"PublicRoomWithTopicCell" forIndexPath:indexPath];
cellWithTopic.roomTopic.text = publicRoom.topic;
cell = cellWithTopic;
} else {
cell = [_publicRoomsTable dequeueReusableCellWithIdentifier:@"PublicRoomCellBasic" forIndexPath:indexPath];
cell = [_publicRoomsTable dequeueReusableCellWithIdentifier:@"PublicRoomCell" forIndexPath:indexPath];
}
// Set room display name
cell.textLabel.text = [publicRoom displayname];
cell.roomDisplayName.text = [publicRoom displayname];
// Set member count
if (publicRoom.numJoinedMembers > 1) {
cell.memberCount.text = [NSString stringWithFormat:@"%lu users", (unsigned long)publicRoom.numJoinedMembers];
} else if (publicRoom.numJoinedMembers == 1) {
cell.memberCount.text = @"1 user";
} else {
cell.memberCount.text = nil;
}
// Highlight?
if (cell.textLabel.text && [highlightedPublicRooms indexOfObject:cell.textLabel.text] != NSNotFound) {
cell.textLabel.font = [UIFont boldSystemFontOfSize:20];
cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:17];
if (cell.roomDisplayName.text && [highlightedPublicRooms indexOfObject:cell.roomDisplayName.text] != NSNotFound) {
cell.roomDisplayName.font = [UIFont boldSystemFontOfSize:20];
if (cellWithTopic) {
cellWithTopic.roomTopic.font = [UIFont boldSystemFontOfSize:17];
}
cell.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
} else {
cell.textLabel.font = [UIFont systemFontOfSize:19];
cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
cell.roomDisplayName.font = [UIFont systemFontOfSize:19];
if (cellWithTopic) {
cellWithTopic.roomTopic.font = [UIFont systemFontOfSize:16];
}
cell.backgroundColor = [UIColor clearColor];
}
return cell;