Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/release-v0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Jan 29, 2016
2 parents d4f230f + 04d43cf commit e503198
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 67 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Changes in MatrixKit in 0.3.1 (2016-01-29)
===============================================

Improvements:
* Upgrade MatrixSDK version (v0.6.1).
* MXKAuthenticationViewController: Keep the current inputs view when it is still relevant after auth flow refresh.
* MXKAuthenticationViewController: Improve scroller content size handling.

Changes in MatrixKit in 0.3.0 (2016-01-22)
===============================================

Expand Down
6 changes: 3 additions & 3 deletions MatrixKit.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixKit"
s.version = "0.3.0"
s.version = "0.3.1"
s.summary = "The Matrix reusable UI library for iOS based on MatrixSDK."

s.description = <<-DESC
Expand All @@ -17,13 +17,13 @@ Pod::Spec.new do |s|

s.platform = :ios, "7.0"

s.source = { :git => "https://github.com/matrix-org/matrix-ios-kit.git", :tag => "v0.3.0" }
s.source = { :git => "https://github.com/matrix-org/matrix-ios-kit.git", :tag => "v0.3.1" }
s.source_files = "MatrixKit", "MatrixKit/**/*.{h,m}"
s.resources = "MatrixKit/**/*.{xib}", "MatrixKit/Assets/MatrixKitAssets.bundle"

s.requires_arc = true

s.dependency 'MatrixSDK', '~> 0.6.0'
s.dependency 'MatrixSDK', '~> 0.6.1'
s.dependency 'HPGrowingTextView', '~> 1.1'
s.dependency 'libPhoneNumber-iOS', '~> 0.8.7'

Expand Down
21 changes: 19 additions & 2 deletions MatrixKit/Controllers/MXKAuthenticationViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extern NSString *const MXKAuthErrorDomain;

@property (weak, nonatomic) IBOutlet UIView *authInputsContainerView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *authInputContainerViewHeightConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *authInputContainerViewMinHeightConstraint;

@property (weak, nonatomic) IBOutlet UILabel *homeServerLabel;
@property (weak, nonatomic) IBOutlet UITextField *homeServerTextField;
Expand All @@ -97,6 +98,11 @@ extern NSString *const MXKAuthErrorDomain;
*/
@property (nonatomic) MXKAuthenticationType authType;

/**
The current selected login flow
*/
@property (nonatomic) MXLoginFlow *selectedFlow;

/**
The default home server url (nil by default).
*/
Expand Down Expand Up @@ -150,13 +156,24 @@ extern NSString *const MXKAuthErrorDomain;
- (void)refreshSupportedAuthFlow;

/**
Customize the MXHTTPClientOnUnrecognizedCertificate block that will be used to handle unrecognized certificate observed
during authentication challenge from a server.
Handle supported flows returned by the server.
*/
- (void)handleHomeServerFlows:(NSArray *)flows;

/**
Customize the MXHTTPClientOnUnrecognizedCertificate block that will be used to handle unrecognized certificate observed during authentication challenge from a server.
By default we prompt the user by displaying a fingerprint (SHA256) of the certificate. The user is then able to trust or not the certificate.
@param onUnrecognizedCertificateBlock
*/
- (void)setOnUnrecognizedCertificateBlock:(MXHTTPClientOnUnrecognizedCertificate)onUnrecognizedCertificateBlock;

/**
Action registered on the following events:
- 'UIControlEventTouchUpInside' for each UIButton instance.
- 'UIControlEventValueChanged' for each UISwitch instance.
*/
- (IBAction)onButtonPressed:(id)sender;

@end

102 changes: 61 additions & 41 deletions MatrixKit/Controllers/MXKAuthenticationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ The current authentication fallback URL (if any).
UIBarButtonItem *cancelFallbackBarButton;
}

/**
The current selected login flow
*/
@property (nonatomic) MXLoginFlow *selectedFlow;

@end

@implementation MXKAuthenticationViewController
Expand Down Expand Up @@ -368,8 +363,6 @@ - (void)refreshSupportedAuthFlow

if (mxRestClient)
{
[_authenticationActivityIndicator startAnimating];
self.selectedFlow = nil;
if (_authType == MXKAuthenticationTypeLogin)
{
mxCurrentOperation = [mxRestClient getLoginFlow:^(NSDictionary *JSONResponse) {
Expand Down Expand Up @@ -592,15 +585,20 @@ - (void)handleHomeServerFlows:(NSArray *)flows
if ((supportedFlows.count != flows.count) && authenticationFallback.length)
{
NSLog(@"[MXKAuthenticationVC] Suggest using fallback page");

// Remove the potential auth inputs view
self.selectedFlow = nil;
}
else if (supportedFlows.count)
{
// FIXME display supported flows
// Currently we select the first one
self.selectedFlow = [supportedFlows firstObject];
}
else
{
if (supportedFlows.count)
{
// FIXME display supported flows
// Currently we select the first one
self.selectedFlow = [supportedFlows firstObject];
}
// Remove the potential auth inputs view
self.selectedFlow = nil;
}

if (!self.selectedFlow)
Expand Down Expand Up @@ -634,22 +632,15 @@ - (void)handleHomeServerFlows:(NSArray *)flows

- (void)setSelectedFlow:(MXLoginFlow *)inSelectedFlow
{
// Hide views which depend on auth flow
_submitButton.hidden = YES;
_noFlowLabel.hidden = YES;
_retryButton.hidden = YES;

[currentAuthInputsView removeFromSuperview];
currentAuthInputsView.delegate = nil;
currentAuthInputsView = nil;
selectedFlow = inSelectedFlow;

// C-S API v2: Consider the first flow from stages as current type
if (inSelectedFlow.type == nil && inSelectedFlow.stages.count)
if (selectedFlow.type == nil && selectedFlow.stages.count)
{
inSelectedFlow.type = inSelectedFlow.stages.firstObject;
selectedFlow.type = selectedFlow.stages.firstObject;
}

// Create the right auth inputs view
// Retrieve the corresponding auth inputs view
NSDictionary *authInputsViewMap;
if (self.authType == MXKAuthenticationTypeLogin)
{
Expand All @@ -660,12 +651,30 @@ - (void)setSelectedFlow:(MXLoginFlow *)inSelectedFlow
authInputsViewMap = registerAuthInputsViewMap;
}

Class class = authInputsViewMap[inSelectedFlow.type];
Class class = authInputsViewMap[selectedFlow.type];

// Keep the current view if it is still relevant
if (currentAuthInputsView && [currentAuthInputsView isKindOfClass:class])
{
return;
}

// Here a new view will be loaded, hide first subviews which depend on auth flow
_submitButton.hidden = YES;
_noFlowLabel.hidden = YES;
_retryButton.hidden = YES;

[currentAuthInputsView removeFromSuperview];
currentAuthInputsView.delegate = nil;
currentAuthInputsView = nil;

if (class)
{
currentAuthInputsView = [class authInputsView];
}

CGFloat previousInputsContainerViewHeight = _authInputContainerViewHeightConstraint.constant;

if (currentAuthInputsView)
{
[_authInputsContainerView addSubview:currentAuthInputsView];
Expand Down Expand Up @@ -701,15 +710,13 @@ - (void)setSelectedFlow:(MXLoginFlow *)inSelectedFlow
else
{
// No input fields are displayed
_authInputContainerViewHeightConstraint.constant = 80;
_authInputContainerViewHeightConstraint.constant = _authInputContainerViewMinHeightConstraint.constant;
}

[self.view layoutIfNeeded];

// Refresh content view height
_contentViewHeightConstraint.constant = _authSwitchButton.frame.origin.y + _authSwitchButton.frame.size.height + 15;

selectedFlow = inSelectedFlow;
// Refresh content view height by considering the updated height of inputs container
_contentViewHeightConstraint.constant += (_authInputContainerViewHeightConstraint.constant - previousInputsContainerViewHeight);
}

- (void)onFailureDuringMXOperation:(NSError*)error
Expand Down Expand Up @@ -737,17 +744,6 @@ - (void)onFailureDuringMXOperation:(NSError*)error
{}];
[alert showInViewController:self];

// Display failure reason
_noFlowLabel.hidden = NO;
_noFlowLabel.text = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
if (!_noFlowLabel.text.length)
{
_noFlowLabel.text = [NSBundle mxk_localizedStringForKey:@"login_error_no_login_flow"];
}
[_retryButton setTitle:[NSBundle mxk_localizedStringForKey:@"retry"] forState:UIControlStateNormal];
[_retryButton setTitle:[NSBundle mxk_localizedStringForKey:@"retry"] forState:UIControlStateNormal];
_retryButton.hidden = NO;

// Handle specific error code here
if ([error.domain isEqualToString:NSURLErrorDomain])
{
Expand All @@ -764,6 +760,30 @@ - (void)onFailureDuringMXOperation:(NSError*)error
[self refreshSupportedAuthFlow];
});
}
else
{
// Remove the potential auth inputs view
self.selectedFlow = nil;
}
}
else
{
// Remove the potential auth inputs view
self.selectedFlow = nil;
}

if (!selectedFlow)
{
// Display failure reason
_noFlowLabel.hidden = NO;
_noFlowLabel.text = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
if (!_noFlowLabel.text.length)
{
_noFlowLabel.text = [NSBundle mxk_localizedStringForKey:@"login_error_no_login_flow"];
}
[_retryButton setTitle:[NSBundle mxk_localizedStringForKey:@"retry"] forState:UIControlStateNormal];
[_retryButton setTitle:[NSBundle mxk_localizedStringForKey:@"retry"] forState:UIControlStateNormal];
_retryButton.hidden = NO;
}
}

Expand Down
6 changes: 4 additions & 2 deletions MatrixKit/Controllers/MXKAuthenticationViewController.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
Expand All @@ -10,6 +10,7 @@
<outlet property="authFallbackContentView" destination="q1e-Wg-6t7" id="mR6-hS-5YB"/>
<outlet property="authFallbackWebView" destination="Vhh-m0-nXN" id="YWJ-8T-74t"/>
<outlet property="authInputContainerViewHeightConstraint" destination="e04-1Y-4gZ" id="5qa-cu-M8v"/>
<outlet property="authInputContainerViewMinHeightConstraint" destination="2s6-K4-8Vv" id="x5P-zJ-hA6"/>
<outlet property="authInputsContainerView" destination="xWb-IJ-v7F" id="DEo-Ji-wPT"/>
<outlet property="authScrollViewBottomConstraint" destination="g7o-eO-7Yr" id="kVv-Xp-aTT"/>
<outlet property="authSwitchButton" destination="FNe-kn-VlD" id="EhA-sr-kiZ"/>
Expand Down Expand Up @@ -37,7 +38,7 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="OHV-KQ-Ww0">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" keyboardDismissMode="onDrag" translatesAutoresizingMaskIntoConstraints="NO" id="OHV-KQ-Ww0">
<rect key="frame" x="0.0" y="20" width="600" height="580"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rhx-dD-4EJ" userLabel="Content View">
Expand Down Expand Up @@ -85,6 +86,7 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerX" secondItem="54b-4O-ip9" secondAttribute="centerX" id="0bV-x1-MhX"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="80" id="2s6-K4-8Vv"/>
<constraint firstItem="54b-4O-ip9" firstAttribute="top" secondItem="xWb-IJ-v7F" secondAttribute="top" constant="8" id="Ddp-gU-nLY"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="54b-4O-ip9" secondAttribute="trailing" constant="8" id="VEQ-w9-9Ln"/>
<constraint firstAttribute="centerY" secondItem="30E-gm-z6O" secondAttribute="centerY" id="ctL-D3-bgP"/>
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Models/Room/MXKRoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ - (void)setEventsFilterForMessages:(NSArray *)eventsFilterForMessages
if ([event.eventId isEqualToString:redactionEvent.redacts])
{
redactedEvent = [event prune];
redactedEvent.redactedBecause = redactionEvent.originalDictionary;
redactedEvent.redactedBecause = redactionEvent.JSONDictionary;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Utils/MXKConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

#import "MXKConstants.h"

NSString *const MatrixKitVersion = @"0.3.0";
NSString *const MatrixKitVersion = @"0.3.1";

NSString *const kMXKErrorNotification = @"kMXKErrorNotification";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand Down Expand Up @@ -55,14 +55,14 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="FVM-ec-tja" firstAttribute="top" secondItem="mbS-mV-L86" secondAttribute="bottom" constant="8" id="0BV-8c-ZVg"/>
<constraint firstAttribute="height" constant="122" id="1nP-RR-5GK"/>
<constraint firstAttribute="centerX" secondItem="mbS-mV-L86" secondAttribute="centerX" id="2R2-Du-o97"/>
<constraint firstAttribute="bottom" secondItem="FVM-ec-tja" secondAttribute="bottom" constant="8" id="7DZ-Wm-ps6"/>
<constraint firstItem="oen-Yq-xJw" firstAttribute="top" secondItem="Nmn-Ry-t32" secondAttribute="top" constant="8" id="BkW-Np-qB3"/>
<constraint firstItem="mbS-mV-L86" firstAttribute="top" secondItem="oen-Yq-xJw" secondAttribute="bottom" constant="8" id="TRx-gf-Afp"/>
<constraint firstAttribute="centerX" secondItem="FVM-ec-tja" secondAttribute="centerX" id="c9K-6H-ufd"/>
<constraint firstItem="mbS-mV-L86" firstAttribute="top" secondItem="vDa-DE-6Bn" secondAttribute="bottom" constant="8" id="cq8-qs-59M"/>
<constraint firstItem="vDa-DE-6Bn" firstAttribute="top" secondItem="Nmn-Ry-t32" secondAttribute="top" constant="8" id="eAp-Ob-hFr"/>
<constraint firstAttribute="width" constant="300" id="fac-n1-3De"/>
<constraint firstAttribute="centerX" secondItem="vDa-DE-6Bn" secondAttribute="centerX" id="otm-qx-iNL"/>
<constraint firstAttribute="centerX" secondItem="oen-Yq-xJw" secondAttribute="centerX" id="s7Y-qf-yrY"/>
</constraints>
Expand All @@ -75,6 +75,7 @@
<outlet property="emailAndTokenTextField" destination="mbS-mV-L86" id="nY5-gT-wGe"/>
<outlet property="promptEmailTokenLabel" destination="vDa-DE-6Bn" id="X3w-5E-0Kg"/>
<outlet property="userLoginTextField" destination="oen-Yq-xJw" id="OM2-gy-O9P"/>
<outlet property="viewHeightConstraint" destination="1nP-RR-5GK" id="s3W-1L-bWN"/>
</connections>
</view>
</objects>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand Down Expand Up @@ -72,7 +72,7 @@
<constraint firstAttribute="centerX" secondItem="odF-W1-Vdr" secondAttribute="centerX" id="BbL-ex-otM"/>
<constraint firstItem="OHZ-Ye-nch" firstAttribute="leading" secondItem="x74-04-ezp" secondAttribute="leading" constant="14" id="Ctv-P7-FQl"/>
<constraint firstItem="6rs-rR-DkS" firstAttribute="top" secondItem="i51-ym-i9T" secondAttribute="bottom" constant="8" id="EJf-md-dcj"/>
<constraint firstAttribute="width" constant="300" id="ERU-Wm-hMV"/>
<constraint firstAttribute="height" constant="179" id="JbD-Ce-bTY"/>
<constraint firstItem="OHZ-Ye-nch" firstAttribute="top" secondItem="odF-W1-Vdr" secondAttribute="bottom" id="LTI-Eq-pH6"/>
<constraint firstAttribute="bottom" secondItem="OHZ-Ye-nch" secondAttribute="bottom" constant="8" id="P2M-2U-Apa"/>
<constraint firstAttribute="centerX" secondItem="i51-ym-i9T" secondAttribute="centerX" id="WKP-y0-Jon"/>
Expand All @@ -92,6 +92,7 @@
<outlet property="emailTextField" destination="odF-W1-Vdr" id="DOS-H7-MZy"/>
<outlet property="passWordTextField" destination="6rs-rR-DkS" id="VeL-kt-Fpp"/>
<outlet property="userLoginTextField" destination="i51-ym-i9T" id="XKi-6m-tFv"/>
<outlet property="viewHeightConstraint" destination="JbD-Ce-bTY" id="09n-jN-RM1"/>
</connections>
</view>
</objects>
Expand Down
2 changes: 2 additions & 0 deletions MatrixKit/Views/Authentication/MXKAuthInputsView.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ typedef enum {
*/
@property (weak, nonatomic) UITextField *displayNameTextField;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *viewHeightConstraint;

/**
* Returns the `UINib` object initialized for the auth inputs view.
*
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Views/Authentication/MXKAuthInputsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (instancetype)init

- (CGFloat)actualHeight
{
return self.frame.size.height;
return _viewHeightConstraint.constant;
}

- (BOOL)areAllRequiredFieldsFilled
Expand Down
2 changes: 1 addition & 1 deletion MatrixKit/Views/MXKEventDetailsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ - (instancetype)initWithEvent:(MXEvent*)event andMatrixSession:(MXSession*)sessi

if (mxEvent)
{
NSMutableDictionary *eventDict = [NSMutableDictionary dictionaryWithDictionary:mxEvent.originalDictionary];
NSMutableDictionary *eventDict = [NSMutableDictionary dictionaryWithDictionary:mxEvent.JSONDictionary];

// Remove event type added by SDK
[eventDict removeObjectForKey:@"event_type"];
Expand Down
Loading

0 comments on commit e503198

Please sign in to comment.