mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-20 14:42:09 +02:00
Update Vector storyboard:
- remove home tab (add public rooms in recents). - remove contacts tab - clean settings
This commit is contained in:
@@ -67,7 +67,7 @@ static RageShakeManager* sharedInstance = nil;
|
||||
- (void)promptCrashReportInViewController:(UIViewController*)viewController {
|
||||
if ([MXLogger crashLog] && [MFMailComposeViewController canSendMail]) {
|
||||
|
||||
confirmationAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"bug_report_prompt", @"MatrixConsole", nil) message:nil style:MXKAlertStyleAlert];
|
||||
confirmationAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"bug_report_prompt", @"Vector", nil) message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[confirmationAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
@@ -110,7 +110,7 @@ static RageShakeManager* sharedInstance = nil;
|
||||
&& (([[NSDate date] timeIntervalSince1970] - startShakingTimeStamp) > RAGESHAKEMANAGER_MINIMUM_SHAKING_DURATION)) {
|
||||
|
||||
if ([responder isKindOfClass:[UIViewController class]] && [MFMailComposeViewController canSendMail]) {
|
||||
confirmationAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"rage_shake_prompt", @"MatrixConsole", nil) message:nil style:MXKAlertStyleAlert];
|
||||
confirmationAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"rage_shake_prompt", @"Vector", nil) message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[confirmationAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
|
||||
+7
-10
@@ -128,7 +128,7 @@
|
||||
_build = buildNumber;
|
||||
} else
|
||||
{
|
||||
_build = buildBranch ? buildBranch : NSLocalizedStringFromTable(@"settings_config_no_build_info", @"MatrixConsole", nil);
|
||||
_build = buildBranch ? buildBranch : NSLocalizedStringFromTable(@"settings_config_no_build_info", @"Vector", nil);
|
||||
}
|
||||
}
|
||||
return _build;
|
||||
@@ -176,8 +176,8 @@
|
||||
self.masterTabBarController = (MasterTabBarController*)self.window.rootViewController;
|
||||
self.masterTabBarController.delegate = self;
|
||||
|
||||
// By default the "Home" tab is focused
|
||||
[self.masterTabBarController setSelectedIndex:TABBAR_HOME_INDEX];
|
||||
// By default the "Recents" tab is focused
|
||||
[self.masterTabBarController setSelectedIndex:TABBAR_RECENTS_INDEX];
|
||||
|
||||
UIViewController* recents = [self.masterTabBarController.viewControllers objectAtIndex:TABBAR_RECENTS_INDEX];
|
||||
if ([recents isKindOfClass:[UISplitViewController class]])
|
||||
@@ -556,9 +556,6 @@
|
||||
// Set up push notifications
|
||||
[self registerUserNotificationSettings];
|
||||
|
||||
// When user is already logged, we launch the app on Recents
|
||||
[self.masterTabBarController setSelectedIndex:TABBAR_RECENTS_INDEX];
|
||||
|
||||
// Observe inApp notifications toggle change for each account
|
||||
for (MXKAccount *account in mxAccounts)
|
||||
{
|
||||
@@ -617,8 +614,8 @@
|
||||
// Reset the contact manager
|
||||
[[MXKContactManager sharedManager] reset];
|
||||
|
||||
// By default the "Home" tab is focussed
|
||||
[self.masterTabBarController setSelectedIndex:TABBAR_HOME_INDEX];
|
||||
// By default the "Recents" tab is focussed
|
||||
[self.masterTabBarController setSelectedIndex:TABBAR_RECENTS_INDEX];
|
||||
}
|
||||
|
||||
- (MXKAlert*)showErrorAsAlert:(NSError*)error
|
||||
@@ -720,7 +717,7 @@
|
||||
weakSelf.mxInAppNotification = nil;
|
||||
[account updateNotificationListenerForRoomId:event.roomId ignore:YES];
|
||||
}];
|
||||
[self.mxInAppNotification addActionWithTitle:NSLocalizedStringFromTable(@"view", @"MatrixConsole", nil)
|
||||
[self.mxInAppNotification addActionWithTitle:NSLocalizedStringFromTable(@"view", @"Vector", nil)
|
||||
style:MXKAlertActionStyleDefault
|
||||
handler:^(MXKAlert *alert)
|
||||
{
|
||||
@@ -1014,7 +1011,7 @@
|
||||
// Create statusBarButton
|
||||
callStatusBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
callStatusBarButton.frame = CGRectMake(0, 0, topBarSize.width,topBarSize.height);
|
||||
NSString *btnTitle = NSLocalizedStringFromTable(@"return_to_call", @"MatrixConsole", nil);
|
||||
NSString *btnTitle = NSLocalizedStringFromTable(@"return_to_call", @"Vector", nil);
|
||||
|
||||
[callStatusBarButton setTitle:btnTitle forState:UIControlStateNormal];
|
||||
[callStatusBarButton setTitle:btnTitle forState:UIControlStateHighlighted];
|
||||
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 536 B |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 723 B |
Binary file not shown.
|
After Width: | Height: | Size: 682 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@@ -18,6 +18,24 @@
|
||||
"recents" = "Recents";
|
||||
"accounts" = "Accounts";
|
||||
|
||||
// Actions
|
||||
"view" = "View";
|
||||
"mark_all_as_read_prompt" = "Mark all as read?";
|
||||
|
||||
// Settings
|
||||
"account_logout_all" = "Logout all accounts";
|
||||
|
||||
"settings_config_ios_console_version" = "Console version: %@";
|
||||
"settings_config_ios_kit_version" = "MatrixKit version: %@";
|
||||
"settings_config_ios_sdk_version" = "MatrixSDK version: %@";
|
||||
"settings_config_build_number" = "Build: %@";
|
||||
"settings_config_no_build_info" = "(no build info)";
|
||||
"settings_title_config" = "Configuration";
|
||||
"settings_clear_cache" = "Clear cache";
|
||||
|
||||
"notification_settings_global_notification_settings" = "Global Notification Settings";
|
||||
|
||||
// Others
|
||||
"public_room_section_title" = "Public Rooms (at %@):";
|
||||
"bug_report_prompt" = "The application has crashed last time. Would you like to submit a crash report?";
|
||||
"rage_shake_prompt" = "You seem to be shaking the phone in frustration. Would you like to submit a bug report?";
|
||||
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="GsA-m1-kGB">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="GsA-m1-kGB">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--RecentsNav-->
|
||||
@@ -27,7 +26,7 @@
|
||||
<navigationItem key="navigationItem" id="3Zt-Wl-J6o">
|
||||
<nil key="title"/>
|
||||
<view key="titleView" contentMode="scaleToFill" id="aas-th-FW1" userLabel="Room title view container">
|
||||
<rect key="frame" x="16" y="2" width="60" height="40"/>
|
||||
<rect key="frame" x="270" y="2" width="60" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
@@ -49,14 +48,6 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1596" y="81"/>
|
||||
</scene>
|
||||
<!--Contact Details View Controller-->
|
||||
<scene sceneID="aUh-hv-QyM">
|
||||
<objects>
|
||||
<tableViewController id="ro1-6w-v07" customClass="MXKContactDetailsViewController" sceneMemberID="viewController"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="cKT-B6-clR" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1517" y="801"/>
|
||||
</scene>
|
||||
<!--Room Members-->
|
||||
<scene sceneID="5AK-8u-TUO">
|
||||
<objects>
|
||||
@@ -86,61 +77,6 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2895" y="488"/>
|
||||
</scene>
|
||||
<!--Home-->
|
||||
<scene sceneID="ZM8-lp-XE5">
|
||||
<objects>
|
||||
<viewController id="U6w-lp-S4A" customClass="HomeViewController" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="vDd-9N-DDP"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="dPJ-aO-2kU"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="RoP-22-pJ3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<searchBar contentMode="redraw" showsCancelButton="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Tvw-ed-GsF">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="eLI-EI-r3h"/>
|
||||
</constraints>
|
||||
<textInputTraits key="textInputTraits" returnKeyType="done"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="U6w-lp-S4A" id="hCd-1N-xoi"/>
|
||||
</connections>
|
||||
</searchBar>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="JaR-EZ-kVC">
|
||||
<rect key="frame" x="0.0" y="44" width="600" height="556"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="U6w-lp-S4A" id="4wm-Hk-riw"/>
|
||||
<outlet property="delegate" destination="U6w-lp-S4A" id="1Td-A7-K3v"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="JaR-EZ-kVC" secondAttribute="bottom" id="4Gb-U6-it8"/>
|
||||
<constraint firstItem="Tvw-ed-GsF" firstAttribute="leading" secondItem="RoP-22-pJ3" secondAttribute="leading" id="729-XV-ZMk"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Tvw-ed-GsF" secondAttribute="trailing" id="Bus-cz-B6K"/>
|
||||
<constraint firstItem="JaR-EZ-kVC" firstAttribute="leading" secondItem="RoP-22-pJ3" secondAttribute="leading" id="I6V-D3-pAd"/>
|
||||
<constraint firstItem="Tvw-ed-GsF" firstAttribute="top" secondItem="RoP-22-pJ3" secondAttribute="top" id="Mow-Cu-hMJ"/>
|
||||
<constraint firstAttribute="trailing" secondItem="JaR-EZ-kVC" secondAttribute="trailing" id="oEj-zz-ioV"/>
|
||||
<constraint firstItem="JaR-EZ-kVC" firstAttribute="top" secondItem="Tvw-ed-GsF" secondAttribute="bottom" id="pmM-LQ-f57"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Home" id="soS-1K-ngS"/>
|
||||
<connections>
|
||||
<outlet property="publicRoomsSearchBar" destination="Tvw-ed-GsF" id="xfg-cb-f7H"/>
|
||||
<outlet property="publicRoomsSearchBarHeightConstraint" destination="eLI-EI-r3h" id="NLK-zk-hqf"/>
|
||||
<outlet property="publicRoomsSearchBarTopConstraint" destination="Mow-Cu-hMJ" id="FKY-yE-XsQ"/>
|
||||
<outlet property="tableView" destination="JaR-EZ-kVC" id="iOr-IF-WMm"/>
|
||||
<outlet property="tableViewBottomConstraint" destination="4Gb-U6-it8" id="WZq-Ll-iM9"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="jbe-3b-94N" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="911" y="-1492"/>
|
||||
</scene>
|
||||
<!--Authentication View Controller-->
|
||||
<scene sceneID="FoA-N2-3aF">
|
||||
<objects>
|
||||
@@ -159,23 +95,6 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="55" y="-2252"/>
|
||||
</scene>
|
||||
<!--HomeNav-->
|
||||
<scene sceneID="whS-JX-66Y">
|
||||
<objects>
|
||||
<navigationController title="HomeNav" id="11T-cf-rgo" sceneMemberID="viewController">
|
||||
<tabBarItem key="tabBarItem" title="Home" image="tab_home.ico" id="aQW-fV-f8t"/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="HZK-D9-mlB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="U6w-lp-S4A" kind="relationship" relationship="rootViewController" id="vCz-RO-a89"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Fpd-U8-xAp" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="49" y="-1492"/>
|
||||
</scene>
|
||||
<!--TabBar-->
|
||||
<scene sceneID="ONA-qQ-ve3">
|
||||
<objects>
|
||||
@@ -188,9 +107,7 @@
|
||||
</tabBar>
|
||||
<connections>
|
||||
<segue destination="ZlD-EU-ncw" kind="presentation" identifier="showAuth" id="Yfo-em-Rs3"/>
|
||||
<segue destination="11T-cf-rgo" kind="relationship" relationship="viewControllers" id="eov-7h-qzl"/>
|
||||
<segue destination="H1p-Uh-vWS" kind="relationship" relationship="viewControllers" id="Iju-mu-cRD"/>
|
||||
<segue destination="fsw-DP-sy3" kind="relationship" relationship="viewControllers" id="8ex-NL-bWb"/>
|
||||
<segue destination="g3a-7T-Pjt" kind="relationship" relationship="viewControllers" id="Y6R-1Q-Uhv"/>
|
||||
</connections>
|
||||
</tabBarController>
|
||||
@@ -198,19 +115,6 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-1041" y="-273"/>
|
||||
</scene>
|
||||
<!--Contacts-->
|
||||
<scene sceneID="ViO-cb-0j7">
|
||||
<objects>
|
||||
<tableViewController id="v0E-AX-Hfa" userLabel="Contacts" customClass="ContactsViewController" sceneMemberID="viewController">
|
||||
<navigationItem key="navigationItem" title="Contacts" id="Ppm-q1-NgB"/>
|
||||
<connections>
|
||||
<segue destination="ro1-6w-v07" kind="show" identifier="showContactDetails" id="8v9-F6-vUy"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="YV3-Df-XS8" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="795" y="801"/>
|
||||
</scene>
|
||||
<!--Settings-->
|
||||
<scene sceneID="4CK-43-kSo">
|
||||
<objects>
|
||||
@@ -314,33 +218,14 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="911" y="81"/>
|
||||
</scene>
|
||||
<!--ContactsNav-->
|
||||
<scene sceneID="HhC-eK-eSS">
|
||||
<objects>
|
||||
<navigationController title="ContactsNav" id="fsw-DP-sy3" sceneMemberID="viewController">
|
||||
<tabBarItem key="tabBarItem" systemItem="contacts" id="nIx-2f-mmH"/>
|
||||
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="gsI-4i-BX6">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="v0E-AX-Hfa" kind="relationship" relationship="rootViewController" id="Jwg-1B-PqQ"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="C6c-tb-ElJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="55" y="802"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="icon_users.png" width="35" height="25"/>
|
||||
<image name="tab_home.ico" width="16" height="16"/>
|
||||
<image name="tab_settings.png" width="25" height="25"/>
|
||||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="Vo4-8x-dtH"/>
|
||||
<segue reference="9Sj-Yf-p2I"/>
|
||||
<segue reference="m9P-N3-WZN"/>
|
||||
<segue reference="17E-G9-IZ6"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
||||
|
||||
@@ -17,8 +17,48 @@
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
/**
|
||||
The data source for Console `RecentsViewController`.
|
||||
The data source for `RecentsViewController` in Vector
|
||||
List the recents (interleaved in only one section in case of multi-sessions) and the available public rooms.
|
||||
A section of public rooms is added for each added REST client.
|
||||
|
||||
Two different types of cell data are handled by this data source: id<MXKRecentCellDataStoring> for the recents
|
||||
and MXPublicRoom* for the public rooms added after the recents list.
|
||||
See publicRoomsFirstSection property to know which type is expected for cell data at a specific indexPath.
|
||||
*/
|
||||
@interface RecentListDataSource : MXKInterleavedRecentsDataSource
|
||||
|
||||
/**
|
||||
The first Public rooms sections (-1 if none).
|
||||
*/
|
||||
@property NSInteger publicRoomsFirstSection;
|
||||
|
||||
/**
|
||||
Add a matrix REST Client. It is used to retrieve public rooms.
|
||||
|
||||
@param restClient a restClient.
|
||||
@param onComplete the callback called once public rooms are updated for this client.
|
||||
*/
|
||||
- (void)addRestClient:(MXRestClient*)restClient onComplete:(void (^)())onComplete;
|
||||
|
||||
/**
|
||||
Remove a matrix REST Client.
|
||||
*/
|
||||
- (void)removeRestClient:(MXRestClient*)restClient;
|
||||
|
||||
/**
|
||||
Refresh public rooms
|
||||
|
||||
@param restClient a restClient, or nil to refresh public rooms for all added client.
|
||||
@param onComplete the callback called once public rooms are updated.
|
||||
*/
|
||||
- (void)refreshPublicRooms:(MXRestClient*)restClient onComplete:(void (^)())onComplete;
|
||||
|
||||
/**
|
||||
Get the public room displayed in the cell at the given index path.
|
||||
|
||||
@param indexPath the index of the cell
|
||||
@return a public room or nil if the provided indexPath does not correspond to a public room section.
|
||||
*/
|
||||
- (MXPublicRoom*)publicRoomAtIndexPath:(NSIndexPath*)indexPath;
|
||||
|
||||
@end
|
||||
|
||||
@@ -18,36 +18,607 @@
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import "NSBundle+MatrixKit.h"
|
||||
|
||||
@interface RecentListDataSource ()
|
||||
{
|
||||
//
|
||||
UIButton *recentsShrinkButton;
|
||||
BOOL areRecentsShrinked;
|
||||
|
||||
// Homeserver list
|
||||
NSMutableArray *homeServers;
|
||||
// All registered REST clients
|
||||
NSMutableArray *restClients;
|
||||
// REST clients by homeserver
|
||||
NSMutableDictionary *restClientDict;
|
||||
// Public rooms by homeserver
|
||||
NSMutableDictionary *publicRoomsDict;
|
||||
// Array of shrinked homeservers.
|
||||
NSMutableArray *shrinkedHomeServers;
|
||||
// Count current refresh requests
|
||||
NSInteger refreshCount;
|
||||
|
||||
// List of public room names to highlight in displayed list
|
||||
NSArray* highlightedPublicRooms;
|
||||
|
||||
// Search in public rooms
|
||||
NSMutableDictionary *filteredPublicRoomsDict;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation RecentListDataSource
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
// Return NO if you do not want the specified item to be editable.
|
||||
return YES;
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
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
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
||||
// Leave the selected room
|
||||
id<MXKRecentCellDataStoring> recentCellData = [self cellDataAtIndexPath:indexPath];
|
||||
- (void)destroy
|
||||
{
|
||||
homeServers = nil;
|
||||
restClients = nil;
|
||||
restClientDict = nil;
|
||||
publicRoomsDict = nil;
|
||||
filteredPublicRoomsDict = nil;
|
||||
shrinkedHomeServers = nil;
|
||||
|
||||
highlightedPublicRooms = nil;
|
||||
|
||||
[super destroy];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)addRestClient:(MXRestClient*)restClient onComplete:(void (^)())onComplete
|
||||
{
|
||||
if (!restClient.homeserver)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!homeServers)
|
||||
{
|
||||
homeServers = [NSMutableArray array];
|
||||
}
|
||||
if (!restClients)
|
||||
{
|
||||
restClients = [NSMutableArray array];
|
||||
}
|
||||
if (!restClientDict)
|
||||
{
|
||||
restClientDict = [NSMutableDictionary dictionary];
|
||||
}
|
||||
|
||||
if ([restClients indexOfObject:restClient] == NSNotFound)
|
||||
{
|
||||
[restClients addObject:restClient];
|
||||
|
||||
// cancel pending uploads/downloads
|
||||
// they are useless by now
|
||||
[MXKMediaManager cancelDownloadsInCacheFolder:recentCellData.roomDataSource.room.state.roomId];
|
||||
// TODO GFO cancel pending uploads related to this room
|
||||
if ([homeServers indexOfObject:restClient.homeserver] == NSNotFound){
|
||||
[homeServers addObject:restClient.homeserver];
|
||||
[restClientDict setObject:restClient forKey:restClient.homeserver];
|
||||
[self refreshPublicRooms:restClient onComplete:onComplete];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeRestClient:(MXRestClient *)restClient
|
||||
{
|
||||
NSUInteger index = [restClients indexOfObject:restClient];
|
||||
if (index != NSNotFound)
|
||||
{
|
||||
[restClients removeObjectAtIndex:index];
|
||||
|
||||
[recentCellData.roomDataSource.room leave:^{
|
||||
// Refresh table display
|
||||
if (self.delegate) {
|
||||
// Check whether this client was reported in rest client dictionary
|
||||
for (NSString *homeserver in homeServers)
|
||||
{
|
||||
if ([restClientDict objectForKey:homeserver] == restClient)
|
||||
{
|
||||
[restClientDict removeObjectForKey:homeserver];
|
||||
BOOL removeHomeServer = YES;
|
||||
|
||||
// Look for an other rest client for this homeserver (if any)
|
||||
for (MXRestClient *client in restClients)
|
||||
{
|
||||
if ([client.homeserver isEqualToString:homeserver])
|
||||
{
|
||||
[restClientDict setObject:client forKey:homeserver];
|
||||
removeHomeServer = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (removeHomeServer)
|
||||
{
|
||||
[homeServers removeObject:homeserver];
|
||||
[publicRoomsDict removeObjectForKey:homeserver];
|
||||
}
|
||||
|
||||
[self refreshPublicRooms:nil onComplete:nil];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeClosedRestClients
|
||||
{
|
||||
// We check here all registered clients (Some of them may have been closed).
|
||||
for (NSInteger index = 0; index < restClients.count; index ++)
|
||||
{
|
||||
MXRestClient *restClient = [restClients objectAtIndex:index];
|
||||
if (!restClient.homeserver.length)
|
||||
{
|
||||
[self removeRestClient:restClient];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)refreshPublicRooms:(MXRestClient*)restClient onComplete:(void (^)())onComplete
|
||||
{
|
||||
NSArray *selectedClients;
|
||||
if (restClient)
|
||||
{
|
||||
selectedClients = @[restClient];
|
||||
}
|
||||
else
|
||||
{
|
||||
// refresh registered clients by removing closed ones.
|
||||
[self removeClosedRestClients];
|
||||
|
||||
// Consider only one client by homeserver.
|
||||
selectedClients = restClientDict.allValues;
|
||||
}
|
||||
|
||||
if (!selectedClients.count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
refreshCount += selectedClients.count;
|
||||
|
||||
if (!publicRoomsDict)
|
||||
{
|
||||
publicRoomsDict = [NSMutableDictionary dictionaryWithCapacity:restClientDict.count];
|
||||
}
|
||||
if (!shrinkedHomeServers)
|
||||
{
|
||||
shrinkedHomeServers = [NSMutableArray array];
|
||||
}
|
||||
|
||||
for (NSInteger index = 0; index < selectedClients.count; index ++)
|
||||
{
|
||||
MXRestClient *restClient = [selectedClients objectAtIndex:index];
|
||||
|
||||
// Retrieve public rooms
|
||||
[restClient publicRooms:^(NSArray *rooms) {
|
||||
|
||||
NSArray *publicRooms = [rooms sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
|
||||
|
||||
MXPublicRoom *firstRoom = (MXPublicRoom*)a;
|
||||
MXPublicRoom *secondRoom = (MXPublicRoom*)b;
|
||||
|
||||
// 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];
|
||||
}
|
||||
}];
|
||||
|
||||
if (publicRooms.count && restClient.homeserver)
|
||||
{
|
||||
[publicRoomsDict setObject:publicRooms forKey:restClient.homeserver];
|
||||
}
|
||||
|
||||
refreshCount--;
|
||||
if (refreshCount == 0)
|
||||
{
|
||||
[self.delegate dataSource:self didCellChange:nil];
|
||||
|
||||
if (onComplete)
|
||||
{
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
} failure:^(NSError *error) {
|
||||
NSLog(@"[Console RecentListDataSource] Failed to leave room (%@) failed: %@", recentCellData.roomDataSource.room.state.roomId, error);
|
||||
|
||||
NSLog(@"[RecentListDataSource] Failed to get public rooms for %@: %@", restClient.homeserver, error);
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
|
||||
refreshCount--;
|
||||
if (refreshCount == 0)
|
||||
{
|
||||
[self.delegate dataSource:self didCellChange:nil];
|
||||
|
||||
if (onComplete)
|
||||
{
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (MXPublicRoom*)publicRoomAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
MXPublicRoom *publicRoom = nil;
|
||||
|
||||
if (_publicRoomsFirstSection != -1 && indexPath.section >= _publicRoomsFirstSection)
|
||||
{
|
||||
NSInteger index = indexPath.section - _publicRoomsFirstSection;
|
||||
if (index < homeServers.count)
|
||||
{
|
||||
NSString *homeserver = [homeServers objectAtIndex:index];
|
||||
NSArray *publicRooms = nil;
|
||||
if (filteredPublicRoomsDict)
|
||||
{
|
||||
publicRooms = [filteredPublicRoomsDict objectForKey:homeserver];
|
||||
}
|
||||
else
|
||||
{
|
||||
publicRooms = [publicRoomsDict objectForKey:homeserver];
|
||||
}
|
||||
|
||||
if (indexPath.row < publicRooms.count)
|
||||
{
|
||||
publicRoom = [publicRooms objectAtIndex:indexPath.row];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return publicRoom;
|
||||
}
|
||||
|
||||
#pragma mark - Override MXKRecentsDataSource
|
||||
|
||||
- (void)addMatrixSession:(MXSession *)matrixSession
|
||||
{
|
||||
[super addMatrixSession:matrixSession];
|
||||
|
||||
[self addRestClient:matrixSession.matrixRestClient onComplete:nil];
|
||||
}
|
||||
|
||||
- (void)removeMatrixSession:(MXSession*)matrixSession
|
||||
{
|
||||
[super removeMatrixSession:matrixSession];
|
||||
|
||||
// Remove the related REST Client
|
||||
if (matrixSession.matrixRestClient)
|
||||
{
|
||||
[self removeRestClient:matrixSession.matrixRestClient];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here the matrix session is closed, the rest client reference has been removed.
|
||||
// Force a full refresh
|
||||
[self refreshPublicRooms:nil onComplete:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)searchWithPatterns:(NSArray*)patternsList
|
||||
{
|
||||
[super searchWithPatterns:patternsList];
|
||||
|
||||
// Update filtered list
|
||||
if (patternsList.count)
|
||||
{
|
||||
if (filteredPublicRoomsDict)
|
||||
{
|
||||
[filteredPublicRoomsDict removeAllObjects];
|
||||
}
|
||||
else
|
||||
{
|
||||
filteredPublicRoomsDict = [NSMutableDictionary dictionaryWithCapacity:homeServers.count];
|
||||
}
|
||||
|
||||
for (NSString* pattern in patternsList)
|
||||
{
|
||||
for (NSString *homeserver in homeServers)
|
||||
{
|
||||
NSArray *publicRooms = [publicRoomsDict objectForKey:homeserver];
|
||||
|
||||
NSMutableArray *filteredRooms = [filteredPublicRoomsDict objectForKey:homeserver];
|
||||
if (!filteredRooms)
|
||||
{
|
||||
filteredRooms = [NSMutableArray array];
|
||||
}
|
||||
|
||||
for (MXPublicRoom *publicRoom in publicRooms)
|
||||
{
|
||||
if ([[publicRoom displayname] rangeOfString:pattern options:NSCaseInsensitiveSearch].location != NSNotFound)
|
||||
{
|
||||
if ([filteredRooms indexOfObject:publicRoom] == NSNotFound)
|
||||
{
|
||||
[filteredRooms addObject:publicRoom];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filteredRooms.count)
|
||||
{
|
||||
[filteredPublicRoomsDict setObject:filteredRooms forKey:homeserver];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filteredPublicRoomsDict = nil;
|
||||
}
|
||||
|
||||
[self.delegate dataSource:self didCellChange:nil];
|
||||
}
|
||||
|
||||
- (CGFloat)cellHeightAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
if (_publicRoomsFirstSection != -1 && indexPath.section >= _publicRoomsFirstSection)
|
||||
{
|
||||
return 60;
|
||||
}
|
||||
return [super cellHeightAtIndexPath:indexPath];
|
||||
}
|
||||
|
||||
- (UIView *)viewForHeaderInSection:(NSInteger)section withFrame:(CGRect)frame
|
||||
{
|
||||
UIView *sectionHeader = nil;
|
||||
NSString* sectionTitle;
|
||||
BOOL isShrinked = NO;
|
||||
NSInteger buttonTag;
|
||||
|
||||
if (section < _publicRoomsFirstSection)
|
||||
{
|
||||
sectionHeader = [super viewForHeaderInSection:section withFrame:frame];
|
||||
|
||||
// Here sectionHeader is nil if there is only one session
|
||||
if (!sectionHeader)
|
||||
{
|
||||
// Let's create a header to shrink recents
|
||||
sectionTitle = self.mxSession.myUser.userId;
|
||||
if (self.unreadCount)
|
||||
{
|
||||
sectionTitle = [NSString stringWithFormat:@"%@ (%tu)", sectionTitle, self.unreadCount];
|
||||
}
|
||||
|
||||
isShrinked = areRecentsShrinked;
|
||||
buttonTag = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *publicRooms = nil;
|
||||
NSString *homeserver;
|
||||
NSInteger index = section - _publicRoomsFirstSection;
|
||||
if (index < homeServers.count)
|
||||
{
|
||||
homeserver = [homeServers objectAtIndex:index];
|
||||
|
||||
if (filteredPublicRoomsDict)
|
||||
{
|
||||
publicRooms = [filteredPublicRoomsDict objectForKey:homeserver];
|
||||
}
|
||||
else
|
||||
{
|
||||
publicRooms = [publicRoomsDict objectForKey:homeserver];
|
||||
}
|
||||
}
|
||||
|
||||
if (publicRooms)
|
||||
{
|
||||
sectionTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"public_room_section_title", @"Vector", nil), homeserver];
|
||||
isShrinked = ([shrinkedHomeServers indexOfObject:homeserver] != NSNotFound);
|
||||
buttonTag = self.displayedRecentsDataSourcesCount + index;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sectionHeader && sectionTitle.length)
|
||||
{
|
||||
sectionHeader = [[UIView alloc] initWithFrame:frame];
|
||||
sectionHeader.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0];
|
||||
|
||||
// Add shrink button
|
||||
UIButton *shrinkButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
CGRect frame = sectionHeader.frame;
|
||||
frame.origin.x = frame.origin.y = 0;
|
||||
shrinkButton.frame = frame;
|
||||
shrinkButton.backgroundColor = [UIColor clearColor];
|
||||
[shrinkButton addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||
shrinkButton.tag = buttonTag;
|
||||
[sectionHeader addSubview:shrinkButton];
|
||||
sectionHeader.userInteractionEnabled = YES;
|
||||
|
||||
// Add shrink icon
|
||||
UIImage *chevron;
|
||||
if (isShrinked)
|
||||
{
|
||||
chevron = [NSBundle mxk_imageFromMXKAssetsBundleWithName:@"disclosure"];
|
||||
}
|
||||
else
|
||||
{
|
||||
chevron = [NSBundle mxk_imageFromMXKAssetsBundleWithName:@"shrink"];
|
||||
}
|
||||
UIImageView *chevronView = [[UIImageView alloc] initWithImage:chevron];
|
||||
chevronView.contentMode = UIViewContentModeCenter;
|
||||
frame = chevronView.frame;
|
||||
frame.origin.x = sectionHeader.frame.size.width - frame.size.width - 8;
|
||||
frame.origin.y = (sectionHeader.frame.size.height - frame.size.height) / 2;
|
||||
chevronView.frame = frame;
|
||||
[sectionHeader addSubview:chevronView];
|
||||
chevronView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin);
|
||||
|
||||
// Add label
|
||||
frame = sectionHeader.frame;
|
||||
frame.origin.x = 5;
|
||||
frame.origin.y = 5;
|
||||
frame.size.width = chevronView.frame.origin.x - 10;
|
||||
frame.size.height -= 10;
|
||||
UILabel *headerLabel = [[UILabel alloc] initWithFrame:frame];
|
||||
headerLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
headerLabel.backgroundColor = [UIColor clearColor];
|
||||
headerLabel.text = sectionTitle;
|
||||
[sectionHeader addSubview:headerLabel];
|
||||
}
|
||||
|
||||
return sectionHeader;
|
||||
}
|
||||
|
||||
- (IBAction)onButtonPressed:(id)sender
|
||||
{
|
||||
if ([sender isKindOfClass:[UIButton class]])
|
||||
{
|
||||
UIButton *shrinkButton = (UIButton*)sender;
|
||||
|
||||
if (shrinkButton.tag < self.displayedRecentsDataSourcesCount)
|
||||
{
|
||||
if (self.displayedRecentsDataSourcesCount > 1)
|
||||
{
|
||||
[super onButtonPressed:sender];
|
||||
}
|
||||
else
|
||||
{
|
||||
areRecentsShrinked = !areRecentsShrinked;
|
||||
[self.delegate dataSource:self didCellChange:nil];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSInteger tag = shrinkButton.tag - self.displayedRecentsDataSourcesCount;
|
||||
if (tag < homeServers.count)
|
||||
{
|
||||
NSString *homeserver = [homeServers objectAtIndex:tag];
|
||||
|
||||
NSUInteger index = [shrinkedHomeServers indexOfObject:homeserver];
|
||||
if (index != NSNotFound)
|
||||
{
|
||||
// Disclose the public rooms list
|
||||
[shrinkedHomeServers removeObjectAtIndex:index];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Shrink the public rooms list from this homeserver.
|
||||
[shrinkedHomeServers addObject:homeserver];
|
||||
}
|
||||
// trigger table refresh
|
||||
[self.delegate dataSource:self didCellChange:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
NSInteger sectionNb = [super numberOfSectionsInTableView:tableView];
|
||||
|
||||
_publicRoomsFirstSection = -1;
|
||||
|
||||
if (homeServers.count)
|
||||
{
|
||||
// Add a section for each list of public rooms
|
||||
_publicRoomsFirstSection = sectionNb;
|
||||
sectionNb += homeServers.count;
|
||||
}
|
||||
|
||||
return sectionNb;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
NSInteger count = 0;
|
||||
|
||||
if (_publicRoomsFirstSection == -1 || section < _publicRoomsFirstSection)
|
||||
{
|
||||
count = [super tableView:tableView numberOfRowsInSection:section];
|
||||
|
||||
if (areRecentsShrinked)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *publicRooms = nil;
|
||||
NSInteger index = section - _publicRoomsFirstSection;
|
||||
if (index < homeServers.count)
|
||||
{
|
||||
NSString *homeserver = [homeServers objectAtIndex:index];
|
||||
|
||||
// Check whether the list is shrinked
|
||||
if ([shrinkedHomeServers indexOfObject:homeserver] == NSNotFound)
|
||||
{
|
||||
if (filteredPublicRoomsDict)
|
||||
{
|
||||
publicRooms = [filteredPublicRoomsDict objectForKey:homeserver];
|
||||
}
|
||||
else
|
||||
{
|
||||
publicRooms = [publicRoomsDict objectForKey:homeserver];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
count = publicRooms.count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
// Public rooms are not editable
|
||||
if (_publicRoomsFirstSection == -1 || indexPath.section < _publicRoomsFirstSection)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell *cell;
|
||||
|
||||
if (_publicRoomsFirstSection == -1 || indexPath.section < _publicRoomsFirstSection)
|
||||
{
|
||||
cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
|
||||
}
|
||||
else
|
||||
{
|
||||
MXKPublicRoomTableViewCell *publicRoomCell = [tableView dequeueReusableCellWithIdentifier:[MXKPublicRoomTableViewCell defaultReuseIdentifier]];
|
||||
if (!publicRoomCell)
|
||||
{
|
||||
publicRoomCell = [[MXKPublicRoomTableViewCell alloc] init];
|
||||
}
|
||||
|
||||
MXPublicRoom *publicRoom = [self publicRoomAtIndexPath:indexPath];
|
||||
if (publicRoom)
|
||||
{
|
||||
[publicRoomCell render:publicRoom];
|
||||
// Highlight?
|
||||
publicRoomCell.focused = (publicRoomCell.roomDisplayName.text && [highlightedPublicRooms indexOfObject:publicRoomCell.roomDisplayName.text] != NSNotFound);
|
||||
}
|
||||
|
||||
cell = publicRoomCell;
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -71,8 +71,8 @@
|
||||
{
|
||||
globalNotifSettingsBtnCell = [[MXKTableViewCellWithButton alloc] init];
|
||||
}
|
||||
[globalNotifSettingsBtnCell.mxkButton setTitle:NSLocalizedStringFromTable(@"notification_settings_global_notification_settings", @"MatrixConsole", nil) forState:UIControlStateNormal];
|
||||
[globalNotifSettingsBtnCell.mxkButton setTitle:NSLocalizedStringFromTable(@"notification_settings_global_notification_settings", @"MatrixConsole", nil) forState:UIControlStateHighlighted];
|
||||
[globalNotifSettingsBtnCell.mxkButton setTitle:NSLocalizedStringFromTable(@"notification_settings_global_notification_settings", @"Vector", nil) forState:UIControlStateNormal];
|
||||
[globalNotifSettingsBtnCell.mxkButton setTitle:NSLocalizedStringFromTable(@"notification_settings_global_notification_settings", @"Vector", nil) forState:UIControlStateHighlighted];
|
||||
[globalNotifSettingsBtnCell.mxkButton addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
globalNotifSettingsButton = globalNotifSettingsBtnCell.mxkButton;
|
||||
|
||||
@@ -1,28 +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 <MatrixKit/MatrixKit.h>
|
||||
|
||||
// SMS
|
||||
#import <MessageUI/MessageUI.h>
|
||||
#import <MessageUI/MFMessageComposeViewController.h>
|
||||
|
||||
/**
|
||||
'ContactsViewController' inherits MXKContactListViewController to handle contact list.
|
||||
*/
|
||||
@interface ContactsViewController : MXKContactListViewController <MXKContactListViewControllerDelegate, MFMessageComposeViewControllerDelegate>
|
||||
@end
|
||||
|
||||
@@ -1,285 +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 "ContactsViewController.h"
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import "RageShakeManager.h"
|
||||
|
||||
#import "NSBundle+MatrixKit.h"
|
||||
|
||||
@interface ContactsViewController ()
|
||||
{
|
||||
/**
|
||||
Tap on thumbnail --> display matrix information.
|
||||
*/
|
||||
MXKContact* selectedContact;
|
||||
}
|
||||
|
||||
@property (strong, nonatomic) MXKAlert *startChatMenu;
|
||||
@property (strong, nonatomic) MXKAlert *allowContactSyncAlert;
|
||||
@end
|
||||
|
||||
@implementation ContactsViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self.tableView setSectionIndexColor:[AppDelegate theDelegate].masterTabBarController.tabBar.tintColor];
|
||||
[self.tableView setSectionIndexBackgroundColor:[UIColor clearColor]];
|
||||
|
||||
// Set rageShake handler
|
||||
self.rageShakeManager = [RageShakeManager sharedManager];
|
||||
|
||||
// The view controller handles itself the selected contact
|
||||
self.delegate = self;
|
||||
}
|
||||
|
||||
- (void)destroy
|
||||
{
|
||||
if (self.startChatMenu)
|
||||
{
|
||||
[self.startChatMenu dismiss:NO];
|
||||
}
|
||||
if (self.allowContactSyncAlert)
|
||||
{
|
||||
[self.allowContactSyncAlert dismiss:NO];
|
||||
}
|
||||
|
||||
selectedContact = nil;
|
||||
|
||||
[super destroy];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (IBAction)onSegmentValueChange:(id)sender
|
||||
{
|
||||
[super onSegmentValueChange:sender];
|
||||
|
||||
if (sender == self.contactsControls)
|
||||
{
|
||||
// Did the user select local contacts?
|
||||
if (self.contactsControls.selectedSegmentIndex)
|
||||
{
|
||||
MXKAppSettings* appSettings = [MXKAppSettings standardAppSettings];
|
||||
|
||||
if (!appSettings.syncLocalContacts)
|
||||
{
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
self.allowContactSyncAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"contact_local_sync_prompt", @"MatrixConsole", nil) message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
[self.allowContactSyncAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"no"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.allowContactSyncAlert = nil;
|
||||
}];
|
||||
|
||||
[self.allowContactSyncAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"yes"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.allowContactSyncAlert = nil;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
appSettings.syncLocalContacts = YES;
|
||||
[weakSelf.tableView reloadData];
|
||||
});
|
||||
}];
|
||||
|
||||
[self.allowContactSyncAlert showInViewController:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MXKContactListViewControllerDelegate
|
||||
|
||||
- (void)contactListViewController:(MXKContactListViewController *)contactListViewController didSelectContact:(NSString*)contactId
|
||||
{
|
||||
MXKContact *contact = [[MXKContactManager sharedManager] contactWithContactID:contactId];
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
NSArray* matrixIDs = contact.matrixIdentifiers;
|
||||
|
||||
// matrix user ?
|
||||
if (matrixIDs.count)
|
||||
{
|
||||
// Display action sheet only if at least one session is available for this user
|
||||
BOOL isSessionAvailable = NO;
|
||||
|
||||
NSArray *mxSessions = self.mxSessions;
|
||||
for (NSString* userID in matrixIDs)
|
||||
{
|
||||
for (MXSession *mxSession in mxSessions)
|
||||
{
|
||||
if ([mxSession userWithUserId:userID])
|
||||
{
|
||||
isSessionAvailable = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isSessionAvailable)
|
||||
{
|
||||
// only 1 matrix ID
|
||||
if (matrixIDs.count == 1)
|
||||
{
|
||||
NSString* matrixID = [matrixIDs objectAtIndex:0];
|
||||
|
||||
self.startChatMenu = [[MXKAlert alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedStringFromTable(@"chat_with_user", @"MatrixConsole", nil), matrixID] message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
[self.startChatMenu addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.startChatMenu = nil;
|
||||
}];
|
||||
|
||||
[self.startChatMenu addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.startChatMenu = nil;
|
||||
|
||||
[[AppDelegate theDelegate] startPrivateOneToOneRoomWithUserId:matrixID];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.startChatMenu = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"chat_with", @"MatrixConsole", nil) message:nil style:MXKAlertStyleActionSheet];
|
||||
|
||||
for(NSString* matrixID in matrixIDs)
|
||||
{
|
||||
[self.startChatMenu addActionWithTitle:matrixID style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.startChatMenu = nil;
|
||||
|
||||
[[AppDelegate theDelegate] startPrivateOneToOneRoomWithUserId:matrixID];
|
||||
}];
|
||||
}
|
||||
|
||||
[self.startChatMenu addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.startChatMenu = nil;
|
||||
}];
|
||||
|
||||
self.startChatMenu.sourceView = self.tableView;
|
||||
}
|
||||
|
||||
[self.startChatMenu showInViewController:self];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// invite to use matrix
|
||||
if (([MFMessageComposeViewController canSendText] ? contact.emailAddresses.count : 0) + (contact.phoneNumbers.count > 0))
|
||||
{
|
||||
|
||||
self.startChatMenu = [[MXKAlert alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedStringFromTable(@"invite_this_user_to_use_matrix", @"MatrixConsole", nil)] message:nil style:MXKAlertStyleActionSheet];
|
||||
|
||||
// check if the target can send SMSes
|
||||
if ([MFMessageComposeViewController canSendText])
|
||||
{
|
||||
// list phonenumbers
|
||||
for(MXKPhoneNumber* phonenumber in contact.phoneNumbers)
|
||||
{
|
||||
[self.startChatMenu addActionWithTitle:phonenumber.textNumber style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.startChatMenu = nil;
|
||||
|
||||
// launch SMS composer
|
||||
MFMessageComposeViewController *messageComposer = [[MFMessageComposeViewController alloc] init];
|
||||
|
||||
if (messageComposer)
|
||||
|
||||
{
|
||||
messageComposer.messageComposeDelegate = weakSelf;
|
||||
messageComposer.body = NSLocalizedStringFromTable(@"invitation_message", @"MatrixConsole", nil);
|
||||
messageComposer.recipients = [NSArray arrayWithObject:phonenumber.textNumber];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf presentViewController:messageComposer animated:YES completion:nil];
|
||||
});
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
// list emails
|
||||
for(MXKEmail* email in contact.emailAddresses)
|
||||
{
|
||||
[self.startChatMenu addActionWithTitle:email.emailAddress style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.startChatMenu = nil;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
NSString* subject = [NSLocalizedStringFromTable(@"invitation_subject", @"MatrixConsole", nil) stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSString* body = [NSLocalizedStringFromTable(@"invitation_message", @"MatrixConsole", nil) stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@&body=%@", email.emailAddress, subject, body]]];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
[self.startChatMenu addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
weakSelf.startChatMenu = nil;
|
||||
}];
|
||||
|
||||
self.startChatMenu.sourceView = self.tableView;
|
||||
[self.startChatMenu showInViewController:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)contactListViewController:(MXKContactListViewController *)contactListViewController didTapContactThumbnail:(NSString*)contactId
|
||||
{
|
||||
MXKContact *contact = [[MXKContactManager sharedManager] contactWithContactID:contactId];
|
||||
|
||||
// open detailled sheet if there
|
||||
if (contact.matrixIdentifiers.count > 0)
|
||||
{
|
||||
selectedContact = contact;
|
||||
[self performSegueWithIdentifier:@"showContactDetails" sender:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Segues
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
|
||||
{
|
||||
// Keep ref on destinationViewController
|
||||
[super prepareForSegue:segue sender:sender];
|
||||
|
||||
if ([segue.identifier isEqualToString:@"showContactDetails"])
|
||||
{
|
||||
MXKContactDetailsViewController *contactDetailsViewController = segue.destinationViewController;
|
||||
// Set rageShake handler
|
||||
contactDetailsViewController.rageShakeManager = [RageShakeManager sharedManager];
|
||||
// Set delegate to handle start chat option
|
||||
contactDetailsViewController.delegate = [AppDelegate theDelegate];
|
||||
|
||||
contactDetailsViewController.contact = selectedContact;
|
||||
selectedContact = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark MFMessageComposeViewControllerDelegate
|
||||
|
||||
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
|
||||
{
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,45 +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 <MatrixKit/MatrixKit.h>
|
||||
|
||||
@interface HomeViewController:MXKViewController <UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate, UITextFieldDelegate, MXKRoomCreationViewDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UISearchBar *publicRoomsSearchBar;
|
||||
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *publicRoomsSearchBarHeightConstraint;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *publicRoomsSearchBarTopConstraint;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableViewBottomConstraint;
|
||||
|
||||
/**
|
||||
Add a matrix REST Client. It is used to make Matrix API requests and retrieve public rooms.
|
||||
*/
|
||||
- (void)addRestClient:(MXRestClient*)restClient;
|
||||
|
||||
/**
|
||||
Remove a matrix REST Client.
|
||||
*/
|
||||
- (void)removeRestClient:(MXRestClient*)restClient;
|
||||
|
||||
/**
|
||||
Enable the search in recents list according to the room display name (YES by default).
|
||||
Set NO this property to disable this option and hide the related bar button.
|
||||
*/
|
||||
@property (nonatomic) BOOL enableSearch;
|
||||
|
||||
@end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,11 +18,9 @@
|
||||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
#define TABBAR_HOME_INDEX 0
|
||||
#define TABBAR_RECENTS_INDEX 1
|
||||
#define TABBAR_CONTACTS_INDEX 2
|
||||
#define TABBAR_SETTINGS_INDEX 3
|
||||
#define TABBAR_COUNT 4
|
||||
#define TABBAR_RECENTS_INDEX 0
|
||||
#define TABBAR_SETTINGS_INDEX 1
|
||||
#define TABBAR_COUNT 2
|
||||
|
||||
@interface MasterTabBarController : UITabBarController
|
||||
|
||||
|
||||
@@ -18,13 +18,9 @@
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import "HomeViewController.h"
|
||||
|
||||
#import "RecentsViewController.h"
|
||||
#import "RecentListDataSource.h"
|
||||
|
||||
#import "ContactsViewController.h"
|
||||
|
||||
#import "SettingsViewController.h"
|
||||
|
||||
@interface MasterTabBarController ()
|
||||
@@ -33,13 +29,10 @@
|
||||
NSMutableArray *mxSessionArray;
|
||||
|
||||
// Tab bar view controllers
|
||||
HomeViewController *homeViewController;
|
||||
|
||||
UINavigationController *recentsNavigationController;
|
||||
RecentsViewController *recentsViewController;
|
||||
|
||||
ContactsViewController *contactsViewController;
|
||||
|
||||
SettingsViewController *settingsViewController;
|
||||
|
||||
// mediaPicker
|
||||
@@ -83,34 +76,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the home view controller
|
||||
UIViewController* home = [self.viewControllers objectAtIndex:TABBAR_HOME_INDEX];
|
||||
if ([home isKindOfClass:[UINavigationController class]])
|
||||
{
|
||||
UINavigationController *homeNavigationController = (UINavigationController*)home;
|
||||
for (UIViewController *viewController in homeNavigationController.viewControllers)
|
||||
{
|
||||
if ([viewController isKindOfClass:[HomeViewController class]])
|
||||
{
|
||||
homeViewController = (HomeViewController*)viewController;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the constacts view controller
|
||||
UIViewController* contacts = [self.viewControllers objectAtIndex:TABBAR_CONTACTS_INDEX];
|
||||
if ([contacts isKindOfClass:[UINavigationController class]])
|
||||
{
|
||||
UINavigationController *contactsNavigationController = (UINavigationController*)contacts;
|
||||
for (UIViewController *viewController in contactsNavigationController.viewControllers)
|
||||
{
|
||||
if ([viewController isKindOfClass:[ContactsViewController class]])
|
||||
{
|
||||
contactsViewController = (ContactsViewController*)viewController;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the settings view controller
|
||||
UIViewController* settings = [self.viewControllers objectAtIndex:TABBAR_SETTINGS_INDEX];
|
||||
if ([settings isKindOfClass:[UINavigationController class]])
|
||||
@@ -126,7 +91,7 @@
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
NSAssert(homeViewController &&recentsViewController && contactsViewController && settingsViewController, @"Something wrong in Main.storyboard");
|
||||
NSAssert(recentsViewController && settingsViewController, @"Something wrong in Main.storyboard");
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
@@ -152,10 +117,8 @@
|
||||
{
|
||||
mxSessionArray = nil;
|
||||
|
||||
homeViewController = nil;
|
||||
recentsNavigationController = nil;
|
||||
recentsViewController = nil;
|
||||
contactsViewController = nil;
|
||||
settingsViewController = nil;
|
||||
|
||||
[self dismissMediaPicker];
|
||||
@@ -204,10 +167,6 @@
|
||||
[recentsViewController.dataSource addMatrixSession:mxSession];
|
||||
}
|
||||
|
||||
// Update home tab
|
||||
[homeViewController addMatrixSession:mxSession];
|
||||
// Update contacts tab
|
||||
[contactsViewController addMatrixSession:mxSession];
|
||||
// Update settings tab
|
||||
[settingsViewController addMatrixSession:mxSession];
|
||||
|
||||
@@ -220,10 +179,6 @@
|
||||
// Update recents data source
|
||||
[recentsViewController.dataSource removeMatrixSession:mxSession];
|
||||
|
||||
// Update home tab
|
||||
[homeViewController removeMatrixSession:mxSession];
|
||||
// Update contacts tab
|
||||
[contactsViewController removeMatrixSession:mxSession];
|
||||
// Update settings tab
|
||||
[settingsViewController removeMatrixSession:mxSession];
|
||||
|
||||
@@ -247,8 +202,7 @@
|
||||
|
||||
- (void)showRoomCreationForm
|
||||
{
|
||||
// Switch in Home Tab
|
||||
[self setSelectedIndex:TABBAR_HOME_INDEX];
|
||||
// TODO
|
||||
}
|
||||
|
||||
- (void)showRoom:(NSString*)roomId withMatrixSession:(MXSession*)mxSession
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#import "NSBundle+MatrixKit.h"
|
||||
|
||||
#import "RecentListDataSource.h"
|
||||
|
||||
@interface RecentsViewController ()
|
||||
{
|
||||
// Recents refresh handling
|
||||
@@ -132,6 +134,15 @@
|
||||
[self.recentsTableView deselectRowAtIndexPath:indexPath animated:NO];
|
||||
}
|
||||
|
||||
RecentListDataSource *recentListDataSource = (RecentListDataSource*)self.dataSource;
|
||||
if (recentListDataSource)
|
||||
{
|
||||
[self startActivityIndicator];
|
||||
[recentListDataSource refreshPublicRooms:nil onComplete:^{
|
||||
[self stopActivityIndicator];
|
||||
}];
|
||||
}
|
||||
|
||||
[self.navigationController.navigationBar addGestureRecognizer:navigationBarTapGesture];
|
||||
}
|
||||
|
||||
@@ -172,6 +183,67 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return 35;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
// Check whether the selected row is a public room or not
|
||||
RecentListDataSource *recentListDataSource = (RecentListDataSource*)self.dataSource;
|
||||
if (recentListDataSource && recentListDataSource.publicRoomsFirstSection != -1 && indexPath.section >= recentListDataSource.publicRoomsFirstSection)
|
||||
{
|
||||
MXPublicRoom *publicRoom = [recentListDataSource publicRoomAtIndexPath:indexPath];
|
||||
if (publicRoom)
|
||||
{
|
||||
// Handle multi-sessions here
|
||||
[[AppDelegate theDelegate] selectMatrixAccount:^(MXKAccount *selectedAccount) {
|
||||
// Check whether the user has already joined the selected public room
|
||||
if ([selectedAccount.mxSession roomWithRoomId:publicRoom.roomId])
|
||||
{
|
||||
// Open selected room
|
||||
[[AppDelegate theDelegate].masterTabBarController showRoom:publicRoom.roomId withMatrixSession:selectedAccount.mxSession];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Join the selected room
|
||||
UIActivityIndicatorView *loadingWheel = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
||||
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
if (selectedCell)
|
||||
{
|
||||
CGPoint center = CGPointMake(selectedCell.frame.size.width / 2, selectedCell.frame.size.height / 2);
|
||||
loadingWheel.center = center;
|
||||
[selectedCell addSubview:loadingWheel];
|
||||
}
|
||||
[loadingWheel startAnimating];
|
||||
[selectedAccount.mxSession joinRoom:publicRoom.roomId success:^(MXRoom *room)
|
||||
{
|
||||
// Show joined room
|
||||
[loadingWheel stopAnimating];
|
||||
[loadingWheel removeFromSuperview];
|
||||
[[AppDelegate theDelegate].masterTabBarController showRoom:publicRoom.roomId withMatrixSession:selectedAccount.mxSession];
|
||||
} failure:^(NSError *error)
|
||||
{
|
||||
NSLog(@"[HomeVC] Failed to join public room (%@): %@", publicRoom.displayname, error);
|
||||
//Alert user
|
||||
[loadingWheel stopAnimating];
|
||||
[loadingWheel removeFromSuperview];
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
}];
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let super handle the selected row
|
||||
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)selectRoomWithId:(NSString*)roomId inMatrixSession:(MXSession*)matrixSession
|
||||
@@ -220,7 +292,7 @@
|
||||
|
||||
- (void)updateNavigationBarTitle
|
||||
{
|
||||
NSString *title = NSLocalizedStringFromTable(@"recents", @"MatrixConsole", nil);
|
||||
NSString *title = NSLocalizedStringFromTable(@"recents", @"Vector", nil);
|
||||
|
||||
if (self.dataSource.unreadCount)
|
||||
{
|
||||
@@ -292,7 +364,7 @@
|
||||
{
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
markAllAsReadAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"mark_all_as_read_prompt", @"MatrixConsole", nil) message:nil style:MXKAlertStyleAlert];
|
||||
markAllAsReadAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"mark_all_as_read_prompt", @"Vector", nil) message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
markAllAsReadAlert.cancelButtonIndex = [markAllAsReadAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"no"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
|
||||
{
|
||||
|
||||
@@ -16,13 +16,7 @@
|
||||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
@interface SettingsViewController : MXKTableViewController <UIPickerViewDataSource, UIPickerViewDelegate>
|
||||
|
||||
/**
|
||||
The application settings displayed in the view controller.
|
||||
By default the shared application settings are considered.
|
||||
*/
|
||||
@property (nonatomic) MXKAppSettings *settings;
|
||||
@interface SettingsViewController : MXKTableViewController
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -21,20 +21,8 @@
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#define SETTINGS_SECTION_ACCOUNTS_INDEX 0
|
||||
#define SETTINGS_SECTION_CONTACTS_INDEX 1
|
||||
#define SETTINGS_SECTION_ROOMS_INDEX 2
|
||||
#define SETTINGS_SECTION_CONFIGURATION_INDEX 3
|
||||
#define SETTINGS_SECTION_COMMANDS_INDEX 4
|
||||
#define SETTINGS_SECTION_COUNT 5
|
||||
|
||||
#define SETTINGS_SECTION_ROOMS_DISPLAY_ALL_EVENTS_INDEX 0
|
||||
#define SETTINGS_SECTION_ROOMS_SHOW_REDACTIONS_INDEX 1
|
||||
#define SETTINGS_SECTION_ROOMS_SHOW_UNSUPPORTED_EVENTS_INDEX 2
|
||||
#define SETTINGS_SECTION_ROOMS_SORT_MEMBERS_INDEX 3
|
||||
#define SETTINGS_SECTION_ROOMS_DISPLAY_LEFT_MEMBERS_INDEX 4
|
||||
#define SETTINGS_SECTION_ROOMS_SET_CACHE_SIZE_INDEX 5
|
||||
#define SETTINGS_SECTION_ROOMS_CLEAR_CACHE_INDEX 6
|
||||
#define SETTINGS_SECTION_ROOMS_INDEX_COUNT 7
|
||||
#define SETTINGS_SECTION_CONFIGURATION_INDEX 1
|
||||
#define SETTINGS_SECTION_COUNT 2
|
||||
|
||||
@interface SettingsViewController ()
|
||||
{
|
||||
@@ -42,25 +30,6 @@
|
||||
id removedAccountObserver;
|
||||
id accountUserInfoObserver;
|
||||
|
||||
// Contacts
|
||||
UISwitch *contactsSyncSwitch;
|
||||
// Country codes management
|
||||
NSArray* countryCodes;
|
||||
NSString* countryCode;
|
||||
NSString* selectedCountryCode;
|
||||
BOOL isSelectingCountryCode;
|
||||
// Dynamic rows in Contacts section
|
||||
NSInteger syncLocalContactsRowIndex;
|
||||
NSInteger countryCodeRowIndex;
|
||||
|
||||
// Rooms settings
|
||||
UISwitch *allEventsSwitch;
|
||||
UISwitch *redactionsSwitch;
|
||||
UISwitch *unsupportedEventsSwitch;
|
||||
UISwitch *sortMembersSwitch;
|
||||
UISwitch *displayLeftMembersSwitch;
|
||||
MXKTableViewCellWithLabelAndSlider* maxCacheSizeCell;
|
||||
NSUInteger minimumCacheSize;
|
||||
UIButton *clearCacheButton;
|
||||
}
|
||||
|
||||
@@ -73,17 +42,6 @@
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
|
||||
// Consider the standard settings by default
|
||||
_settings = [MXKAppSettings standardAppSettings];
|
||||
|
||||
// Initialize the minimum cache size with the current value
|
||||
minimumCacheSize = self.minCachesSize;
|
||||
|
||||
// country selection
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"countryCodes" ofType:@"plist"];
|
||||
countryCodes = [NSArray arrayWithContentsOfFile:path];
|
||||
isSelectingCountryCode = NO;
|
||||
|
||||
// Setup `MXKRoomMemberListViewController` properties
|
||||
self.rageShakeManager = [RageShakeManager sharedManager];
|
||||
|
||||
@@ -141,20 +99,6 @@
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
if (!_settings)
|
||||
{
|
||||
// Consider the standard settings by default
|
||||
_settings = [MXKAppSettings standardAppSettings];
|
||||
}
|
||||
|
||||
selectedCountryCode = countryCode = [_settings phonebookCountryCode];
|
||||
|
||||
// Update the minimum cache size with the current value
|
||||
// Dispatch this operation to not freeze the app
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
minimumCacheSize = self.minCachesSize;
|
||||
});
|
||||
|
||||
// Refresh display
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
@@ -162,18 +106,6 @@
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
|
||||
// if country has been updated
|
||||
// update the contact phonenumbers
|
||||
// and check if they match now to Matrix Users
|
||||
if (![countryCode isEqualToString:selectedCountryCode])
|
||||
{
|
||||
|
||||
[_settings setPhonebookCountryCode:selectedCountryCode];
|
||||
countryCode = selectedCountryCode;
|
||||
}
|
||||
|
||||
countryCode = [_settings phonebookCountryCode];
|
||||
}
|
||||
|
||||
#pragma mark - Internal methods
|
||||
@@ -196,15 +128,7 @@
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
selectedAccount = nil;
|
||||
|
||||
contactsSyncSwitch = nil;
|
||||
|
||||
allEventsSwitch = nil;
|
||||
redactionsSwitch = nil;
|
||||
unsupportedEventsSwitch = nil;
|
||||
sortMembersSwitch = nil;
|
||||
displayLeftMembersSwitch = nil;
|
||||
maxCacheSizeCell = nil;
|
||||
|
||||
clearCacheButton = nil;
|
||||
}
|
||||
|
||||
@@ -238,65 +162,12 @@
|
||||
|
||||
- (IBAction)onButtonPressed:(id)sender
|
||||
{
|
||||
if (sender == allEventsSwitch)
|
||||
{
|
||||
_settings.showAllEventsInRoomHistory = allEventsSwitch.on;
|
||||
}
|
||||
else if (sender == redactionsSwitch)
|
||||
{
|
||||
_settings.showRedactionsInRoomHistory = redactionsSwitch.on;
|
||||
}
|
||||
else if (sender == unsupportedEventsSwitch)
|
||||
{
|
||||
_settings.showUnsupportedEventsInRoomHistory = unsupportedEventsSwitch.on;
|
||||
}
|
||||
else if (sender == sortMembersSwitch)
|
||||
{
|
||||
_settings.sortRoomMembersUsingLastSeenTime = sortMembersSwitch.on;
|
||||
}
|
||||
else if (sender == displayLeftMembersSwitch)
|
||||
{
|
||||
_settings.showLeftMembersInRoomMemberList = displayLeftMembersSwitch.on;
|
||||
}
|
||||
else if (sender == contactsSyncSwitch)
|
||||
{
|
||||
_settings.syncLocalContacts = contactsSyncSwitch.on;
|
||||
isSelectingCountryCode = NO;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.tableView reloadData];
|
||||
});
|
||||
}
|
||||
else if (sender == clearCacheButton)
|
||||
if (sender == clearCacheButton)
|
||||
{
|
||||
[[AppDelegate theDelegate] reloadMatrixSessions:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)onSliderValueChange:(id)sender
|
||||
{
|
||||
if (sender == maxCacheSizeCell.mxkSlider)
|
||||
{
|
||||
UISlider* slider = maxCacheSizeCell.mxkSlider;
|
||||
|
||||
// check if the upper bounds have been updated
|
||||
if (slider.maximumValue != self.maxAllowedCachesSize)
|
||||
{
|
||||
slider.maximumValue = self.maxAllowedCachesSize;
|
||||
}
|
||||
|
||||
// check if the value does not exceed the bounds
|
||||
if (slider.value < minimumCacheSize)
|
||||
{
|
||||
slider.value = minimumCacheSize;
|
||||
}
|
||||
|
||||
[self setCurrentMaxCachesSize:slider.value];
|
||||
|
||||
maxCacheSizeCell.mxkLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_max_cache_size", @"MatrixConsole", nil), [NSByteCountFormatter stringFromByteCount:self.currentMaxCachesSize countStyle:NSByteCountFormatterCountStyleFile]];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Segues
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
|
||||
@@ -326,28 +197,9 @@
|
||||
{
|
||||
count = [[MXKAccountManager sharedManager] accounts].count + 1; // Add one cell in this section to display "logout all" option.
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_CONTACTS_INDEX)
|
||||
{
|
||||
countryCodeRowIndex = syncLocalContactsRowIndex = -1;
|
||||
|
||||
// init row index
|
||||
syncLocalContactsRowIndex = count++;
|
||||
if ([_settings syncLocalContacts])
|
||||
{
|
||||
countryCodeRowIndex = count++;
|
||||
}
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_ROOMS_INDEX)
|
||||
{
|
||||
count = SETTINGS_SECTION_ROOMS_INDEX_COUNT;
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_CONFIGURATION_INDEX)
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_COMMANDS_INDEX)
|
||||
{
|
||||
count = 1;
|
||||
count = 2;
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -387,8 +239,8 @@
|
||||
{
|
||||
logoutBtnCell = [[MXKTableViewCellWithButton alloc] init];
|
||||
}
|
||||
[logoutBtnCell.mxkButton setTitle:NSLocalizedStringFromTable(@"account_logout_all", @"MatrixConsole", nil) forState:UIControlStateNormal];
|
||||
[logoutBtnCell.mxkButton setTitle:NSLocalizedStringFromTable(@"account_logout_all", @"MatrixConsole", nil) forState:UIControlStateHighlighted];
|
||||
[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];
|
||||
@@ -396,82 +248,27 @@
|
||||
cell = logoutBtnCell;
|
||||
}
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_CONTACTS_INDEX)
|
||||
else if (indexPath.section == SETTINGS_SECTION_CONFIGURATION_INDEX)
|
||||
{
|
||||
if (indexPath.row == syncLocalContactsRowIndex)
|
||||
if (indexPath.row == 0)
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSwitch *contactsCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithLabelAndSwitch defaultReuseIdentifier]];
|
||||
if (!contactsCell)
|
||||
MXKTableViewCellWithTextView *configurationCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]];
|
||||
if (!configurationCell)
|
||||
{
|
||||
contactsCell = [[MXKTableViewCellWithLabelAndSwitch alloc] init];
|
||||
configurationCell = [[MXKTableViewCellWithTextView alloc] init];
|
||||
}
|
||||
|
||||
[contactsCell.mxkSwitch addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
contactsCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_contact_sync", @"MatrixConsole", nil);
|
||||
contactsCell.mxkSwitch.on = [_settings syncLocalContacts];
|
||||
contactsSyncSwitch = contactsCell.mxkSwitch;
|
||||
cell = contactsCell;
|
||||
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;
|
||||
}
|
||||
else if (indexPath.row == countryCodeRowIndex)
|
||||
{
|
||||
int index = 0;
|
||||
NSString* countryName = @"";
|
||||
|
||||
for(NSDictionary* dict in countryCodes)
|
||||
{
|
||||
if ([[dict valueForKey:@"id"] isEqualToString:selectedCountryCode])
|
||||
{
|
||||
countryName = [dict valueForKey:@"country"];
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
// there is no country code selection
|
||||
if (!isSelectingCountryCode)
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSubLabel *countryCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithLabelAndSubLabel defaultReuseIdentifier]];
|
||||
if (!countryCell)
|
||||
{
|
||||
countryCell = [[MXKTableViewCellWithLabelAndSubLabel alloc] init];
|
||||
}
|
||||
|
||||
countryCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_country_select", @"MatrixConsole", nil);
|
||||
countryCell.mxkSublabel.text = countryName;
|
||||
countryCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
cell = countryCell;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is a selection in progress
|
||||
MXKTableViewCellWithPicker *pickerCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithPicker defaultReuseIdentifier]];
|
||||
if (!pickerCell)
|
||||
{
|
||||
pickerCell = [[MXKTableViewCellWithPicker alloc] init];
|
||||
}
|
||||
|
||||
// display a picker
|
||||
pickerCell.mxkPickerView.delegate = self;
|
||||
pickerCell.mxkPickerView.dataSource = self;
|
||||
|
||||
if (countryName.length > 0)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[pickerCell.mxkPickerView selectRow:index inComponent:0 animated:NO];
|
||||
});
|
||||
}
|
||||
|
||||
cell = pickerCell;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_ROOMS_INDEX)
|
||||
{
|
||||
if (indexPath.row == SETTINGS_SECTION_ROOMS_CLEAR_CACHE_INDEX)
|
||||
else if (indexPath.row == 1)
|
||||
{
|
||||
MXKTableViewCellWithButton *clearCacheBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]];
|
||||
if (!clearCacheBtnCell)
|
||||
@@ -479,7 +276,7 @@
|
||||
clearCacheBtnCell = [[MXKTableViewCellWithButton alloc] init];
|
||||
}
|
||||
|
||||
NSString *btnTitle = [NSString stringWithFormat:@"%@ (%@)", NSLocalizedStringFromTable(@"settings_clear_cache", @"MatrixConsole", nil), [NSByteCountFormatter stringFromByteCount:self.cachesSize countStyle:NSByteCountFormatterCountStyleFile]];
|
||||
NSString *btnTitle = [NSString stringWithFormat:@"%@", NSLocalizedStringFromTable(@"settings_clear_cache", @"Vector", nil)];
|
||||
[clearCacheBtnCell.mxkButton setTitle:btnTitle forState:UIControlStateNormal];
|
||||
[clearCacheBtnCell.mxkButton setTitle:btnTitle forState:UIControlStateHighlighted];
|
||||
|
||||
@@ -490,95 +287,6 @@
|
||||
|
||||
cell = clearCacheBtnCell;
|
||||
}
|
||||
else if (indexPath.row == SETTINGS_SECTION_ROOMS_SET_CACHE_SIZE_INDEX)
|
||||
{
|
||||
maxCacheSizeCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithLabelAndSlider defaultReuseIdentifier]];
|
||||
if (!maxCacheSizeCell)
|
||||
{
|
||||
maxCacheSizeCell = [[MXKTableViewCellWithLabelAndSlider alloc] init];
|
||||
}
|
||||
|
||||
maxCacheSizeCell.mxkSlider.minimumValue = 0;
|
||||
maxCacheSizeCell.mxkSlider.maximumValue = self.maxAllowedCachesSize;
|
||||
maxCacheSizeCell.mxkSlider.value = self.currentMaxCachesSize;
|
||||
|
||||
[self onSliderValueChange:maxCacheSizeCell.mxkSlider];
|
||||
|
||||
[maxCacheSizeCell.mxkSlider addTarget:self action:@selector(onSliderValueChange:) forControlEvents:UIControlEventValueChanged];
|
||||
cell = maxCacheSizeCell;
|
||||
}
|
||||
else
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSwitch *roomsSettingCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithLabelAndSwitch defaultReuseIdentifier]];
|
||||
if (!roomsSettingCell)
|
||||
{
|
||||
roomsSettingCell = [[MXKTableViewCellWithLabelAndSwitch alloc] init];
|
||||
}
|
||||
|
||||
[roomsSettingCell.mxkSwitch addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
if (indexPath.row == SETTINGS_SECTION_ROOMS_DISPLAY_ALL_EVENTS_INDEX)
|
||||
{
|
||||
roomsSettingCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_display_all_events", @"MatrixConsole", nil);
|
||||
roomsSettingCell.mxkSwitch.on = [_settings showAllEventsInRoomHistory];
|
||||
allEventsSwitch = roomsSettingCell.mxkSwitch;
|
||||
}
|
||||
else if (indexPath.row == SETTINGS_SECTION_ROOMS_SHOW_REDACTIONS_INDEX)
|
||||
{
|
||||
roomsSettingCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_show_redactions", @"MatrixConsole", nil);
|
||||
roomsSettingCell.mxkSwitch.on = [_settings showRedactionsInRoomHistory];
|
||||
redactionsSwitch = roomsSettingCell.mxkSwitch;
|
||||
}
|
||||
else if (indexPath.row == SETTINGS_SECTION_ROOMS_SHOW_UNSUPPORTED_EVENTS_INDEX)
|
||||
{
|
||||
roomsSettingCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_show_unsupported_events", @"MatrixConsole", nil);
|
||||
roomsSettingCell.mxkSwitch.on = [_settings showUnsupportedEventsInRoomHistory];
|
||||
unsupportedEventsSwitch = roomsSettingCell.mxkSwitch;
|
||||
}
|
||||
else if (indexPath.row == SETTINGS_SECTION_ROOMS_SORT_MEMBERS_INDEX)
|
||||
{
|
||||
roomsSettingCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_sort_by_last_seen", @"MatrixConsole", nil);
|
||||
roomsSettingCell.mxkSwitch.on = [_settings sortRoomMembersUsingLastSeenTime];
|
||||
sortMembersSwitch = roomsSettingCell.mxkSwitch;
|
||||
}
|
||||
else if (indexPath.row == SETTINGS_SECTION_ROOMS_DISPLAY_LEFT_MEMBERS_INDEX)
|
||||
{
|
||||
roomsSettingCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_display_left_members", @"MatrixConsole", nil);
|
||||
roomsSettingCell.mxkSwitch.on = [_settings showLeftMembersInRoomMemberList];
|
||||
displayLeftMembersSwitch = roomsSettingCell.mxkSwitch;
|
||||
}
|
||||
|
||||
cell = roomsSettingCell;
|
||||
}
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_CONFIGURATION_INDEX)
|
||||
{
|
||||
MXKTableViewCellWithTextView *configurationCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]];
|
||||
if (!configurationCell)
|
||||
{
|
||||
configurationCell = [[MXKTableViewCellWithTextView alloc] init];
|
||||
}
|
||||
|
||||
NSString* appVersion = [AppDelegate theDelegate].appVersion;
|
||||
NSString* build = [AppDelegate theDelegate].build;
|
||||
if (build.length)
|
||||
{
|
||||
build = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_config_build_number", @"MatrixConsole", nil), build];
|
||||
}
|
||||
NSString *configurationFormatText = [NSString stringWithFormat:@"%@\n%@\n%@\n%@", NSLocalizedStringFromTable(@"settings_config_ios_console_version", @"MatrixConsole", nil), NSLocalizedStringFromTable(@"settings_config_ios_kit_version", @"MatrixConsole", nil), NSLocalizedStringFromTable(@"settings_config_ios_sdk_version", @"MatrixConsole", nil), @"%@"];
|
||||
configurationCell.mxkTextView.text = [NSString stringWithFormat:configurationFormatText, appVersion, MatrixKitVersion, MatrixSDKVersion, build];
|
||||
cell = configurationCell;
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_COMMANDS_INDEX)
|
||||
{
|
||||
MXKTableViewCellWithTextView *commandsCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]];
|
||||
if (!commandsCell)
|
||||
{
|
||||
commandsCell = [[MXKTableViewCellWithTextView alloc] init];
|
||||
}
|
||||
|
||||
commandsCell.mxkTextView.text = NSLocalizedStringFromTable(@"settings_command_commands", @"MatrixConsole", nil);
|
||||
cell = commandsCell;
|
||||
}
|
||||
|
||||
return cell;
|
||||
@@ -592,23 +300,7 @@
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_CONTACTS_INDEX)
|
||||
{
|
||||
|
||||
if ((indexPath.row == countryCodeRowIndex) && isSelectingCountryCode)
|
||||
{
|
||||
|
||||
return 164;
|
||||
}
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_ROOMS_INDEX)
|
||||
{
|
||||
if (indexPath.row == SETTINGS_SECTION_ROOMS_SET_CACHE_SIZE_INDEX)
|
||||
{
|
||||
return 88;
|
||||
}
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_CONFIGURATION_INDEX)
|
||||
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];
|
||||
@@ -616,21 +308,13 @@
|
||||
NSString* build = [AppDelegate theDelegate].build;
|
||||
if (build.length)
|
||||
{
|
||||
build = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_config_build_number", @"MatrixConsole", nil), build];
|
||||
build = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_config_build_number", @"Vector", nil), build];
|
||||
}
|
||||
NSString *configurationFormatText = [NSString stringWithFormat:@"%@\n%@\n%@\n%@", NSLocalizedStringFromTable(@"settings_config_ios_console_version", @"MatrixConsole", nil), NSLocalizedStringFromTable(@"settings_config_ios_kit_version", @"MatrixConsole", nil), NSLocalizedStringFromTable(@"settings_config_ios_sdk_version", @"MatrixConsole", nil), @"%@"];
|
||||
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;
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_COMMANDS_INDEX)
|
||||
{
|
||||
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, MAXFLOAT)];
|
||||
textView.font = [UIFont systemFontOfSize:14];
|
||||
textView.text = NSLocalizedStringFromTable(@"settings_command_commands", @"MatrixConsole", nil);
|
||||
CGSize contentSize = [textView sizeThatFits:textView.frame.size];
|
||||
return contentSize.height + 1;
|
||||
}
|
||||
|
||||
return 44;
|
||||
}
|
||||
@@ -656,7 +340,7 @@
|
||||
|
||||
if (section == SETTINGS_SECTION_ACCOUNTS_INDEX)
|
||||
{
|
||||
sectionLabel.text = NSLocalizedStringFromTable(@"accounts", @"MatrixConsole", nil);
|
||||
sectionLabel.text = NSLocalizedStringFromTable(@"accounts", @"Vector", nil);
|
||||
|
||||
UIButton *addAccount = [UIButton buttonWithType:UIButtonTypeContactAdd];
|
||||
[addAccount addTarget:self action:@selector(addAccount:) forControlEvents:UIControlEventTouchUpInside];
|
||||
@@ -671,21 +355,9 @@
|
||||
|
||||
sectionHeader.userInteractionEnabled = YES;
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_CONTACTS_INDEX)
|
||||
{
|
||||
sectionLabel.text = NSLocalizedStringFromTable(@"contacts", @"MatrixConsole", nil);
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_ROOMS_INDEX)
|
||||
{
|
||||
sectionLabel.text = NSLocalizedStringFromTable(@"settings_title_rooms", @"MatrixConsole", nil);
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_CONFIGURATION_INDEX)
|
||||
{
|
||||
sectionLabel.text = NSLocalizedStringFromTable(@"settings_title_config", @"MatrixConsole", nil);
|
||||
}
|
||||
else if (section == SETTINGS_SECTION_COMMANDS_INDEX)
|
||||
{
|
||||
sectionLabel.text = NSLocalizedStringFromTable(@"settings_title_commands", @"MatrixConsole", nil);
|
||||
sectionLabel.text = NSLocalizedStringFromTable(@"settings_title_config", @"Vector", nil);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -708,104 +380,8 @@
|
||||
[self performSegueWithIdentifier:@"showAccountDetails" sender:self];
|
||||
}
|
||||
}
|
||||
else if (indexPath.section == SETTINGS_SECTION_CONTACTS_INDEX)
|
||||
{
|
||||
if (indexPath.row == countryCodeRowIndex)
|
||||
{
|
||||
isSelectingCountryCode = YES;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.tableView reloadData];
|
||||
});
|
||||
}
|
||||
}
|
||||
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UIPickerViewDataSource
|
||||
|
||||
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
|
||||
{
|
||||
return [countryCodes count];
|
||||
}
|
||||
|
||||
#pragma mark - UIPickerViewDelegate
|
||||
|
||||
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
|
||||
{
|
||||
return [[countryCodes objectAtIndex:row] valueForKey:@"country"];
|
||||
}
|
||||
|
||||
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
|
||||
{
|
||||
// sanity check
|
||||
if ((row >= 0) && (row < countryCodes.count))
|
||||
{
|
||||
NSDictionary* dict = [countryCodes objectAtIndex:row];
|
||||
selectedCountryCode = [dict valueForKey:@"id"];
|
||||
}
|
||||
|
||||
isSelectingCountryCode = NO;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.tableView reloadData];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - Cache handling
|
||||
|
||||
// return the MX cache size in bytes
|
||||
- (NSUInteger)MXCacheSize
|
||||
{
|
||||
NSUInteger cacheSize = 0;
|
||||
|
||||
NSArray *mxSessions = self.mxSessions;
|
||||
for (MXSession *mxSession in mxSessions)
|
||||
{
|
||||
if (mxSession.store && [mxSession.store isKindOfClass:[MXFileStore class]])
|
||||
{
|
||||
MXFileStore *fileStore = (MXFileStore*)mxSession.store;
|
||||
cacheSize += fileStore.diskUsage;
|
||||
}
|
||||
}
|
||||
|
||||
return cacheSize;
|
||||
}
|
||||
|
||||
// return the sum of the caches (MX cache + media cache ...) in bytes
|
||||
- (NSUInteger)cachesSize
|
||||
{
|
||||
return self.MXCacheSize + [MXKMediaManager cacheSize];
|
||||
}
|
||||
|
||||
// defines the min allow cache size in bytes
|
||||
- (NSUInteger)minCachesSize
|
||||
{
|
||||
// add a 50MB margin to avoid cache file deletion
|
||||
return self.MXCacheSize + [MXKMediaManager minCacheSize] + 50 * 1024 * 1024;
|
||||
}
|
||||
|
||||
// defines the current max caches size in bytes
|
||||
- (NSUInteger)currentMaxCachesSize
|
||||
{
|
||||
return self.MXCacheSize + [MXKMediaManager currentMaxCacheSize];
|
||||
}
|
||||
|
||||
- (void)setCurrentMaxCachesSize:(NSUInteger)maxCachesSize
|
||||
{
|
||||
[MXKMediaManager setCurrentMaxCacheSize:maxCachesSize - self.MXCacheSize];
|
||||
}
|
||||
|
||||
// defines the max allowed caches size in bytes
|
||||
- (NSUInteger) maxAllowedCachesSize
|
||||
{
|
||||
return self.MXCacheSize + [MXKMediaManager maxAllowedCacheSize];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user