mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Console: Replace MXCAlert with MXKAlert from matrix kit.
This commit is contained in:
parent
3b41617b82
commit
d0bea40f64
12 changed files with 59 additions and 356 deletions
|
@ -54,7 +54,6 @@
|
|||
F04B2DA51A977A9B00EEA4C8 /* tab_settings.png in Resources */ = {isa = PBXBuildFile; fileRef = F04B2DA11A977A9B00EEA4C8 /* tab_settings.png */; };
|
||||
F04B2DA61A977A9B00EEA4C8 /* tab_settings@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F04B2DA21A977A9B00EEA4C8 /* tab_settings@2x.png */; };
|
||||
F052377C1A7289F00079F3E0 /* APNSHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = F05237791A7289F00079F3E0 /* APNSHandler.m */; };
|
||||
F05237801A728A010079F3E0 /* MXCAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = F052377F1A728A010079F3E0 /* MXCAlert.m */; };
|
||||
F05237831A728A0A0079F3E0 /* MXCGrowingTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = F05237821A728A0A0079F3E0 /* MXCGrowingTextView.m */; };
|
||||
F05C3A3E1A3F3D7F002B698E /* icon_users.png in Resources */ = {isa = PBXBuildFile; fileRef = F05C3A3C1A3F3D7F002B698E /* icon_users.png */; };
|
||||
F05C3A3F1A3F3D7F002B698E /* icon_users@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F05C3A3D1A3F3D7F002B698E /* icon_users@2x.png */; };
|
||||
|
@ -175,8 +174,6 @@
|
|||
F04B2DA21A977A9B00EEA4C8 /* tab_settings@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tab_settings@2x.png"; sourceTree = "<group>"; };
|
||||
F05237781A7289F00079F3E0 /* APNSHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APNSHandler.h; sourceTree = "<group>"; };
|
||||
F05237791A7289F00079F3E0 /* APNSHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APNSHandler.m; sourceTree = "<group>"; };
|
||||
F052377E1A728A010079F3E0 /* MXCAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXCAlert.h; sourceTree = "<group>"; };
|
||||
F052377F1A728A010079F3E0 /* MXCAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCAlert.m; sourceTree = "<group>"; };
|
||||
F05237811A728A0A0079F3E0 /* MXCGrowingTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXCGrowingTextView.h; sourceTree = "<group>"; };
|
||||
F05237821A728A0A0079F3E0 /* MXCGrowingTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCGrowingTextView.m; sourceTree = "<group>"; };
|
||||
F05C3A3C1A3F3D7F002B698E /* icon_users.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_users.png; sourceTree = "<group>"; };
|
||||
|
@ -381,8 +378,6 @@
|
|||
children = (
|
||||
F08E67921A77965A00AABD4C /* MXC3PID.h */,
|
||||
F08E67931A77965A00AABD4C /* MXC3PID.m */,
|
||||
F052377E1A728A010079F3E0 /* MXCAlert.h */,
|
||||
F052377F1A728A010079F3E0 /* MXCAlert.m */,
|
||||
71193D301A6E49F000E59A9E /* MXCContact.h */,
|
||||
71193D311A6E49F000E59A9E /* MXCContact.m */,
|
||||
710CC3C01A70F28F006EE973 /* MXCContactField.h */,
|
||||
|
@ -664,7 +659,6 @@
|
|||
71193D3B1A6E50EC00E59A9E /* ContactManager.m in Sources */,
|
||||
71193D2C1A6E433900E59A9E /* ContactTableCell.m in Sources */,
|
||||
F02D707619F1DC9E007B47D3 /* RoomMemberTableCell.m in Sources */,
|
||||
F05237801A728A010079F3E0 /* MXCAlert.m in Sources */,
|
||||
F00B5DB91A1B9BCE00EA1C8D /* MXCImageView.m in Sources */,
|
||||
F0D3C30C1A011EF10000D49E /* AppSettings.m in Sources */,
|
||||
F05237831A728A0A0079F3E0 /* MXCGrowingTextView.m in Sources */,
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#import "MatrixSDKHandler.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "AppSettings.h"
|
||||
#import "MXCAlert.h"
|
||||
|
||||
#import "MXFileStore.h"
|
||||
#import "MXTools.h"
|
||||
|
@ -51,7 +50,7 @@ static MatrixSDKHandler *sharedHandler = nil;
|
|||
@property (strong, nonatomic) MXFileStore *mxFileStore;
|
||||
@property (nonatomic,readwrite) MatrixSDKHandlerStatus status;
|
||||
@property (nonatomic,readwrite) BOOL isActivityInProgress;
|
||||
@property (strong, nonatomic) MXCAlert *mxNotification;
|
||||
@property (strong, nonatomic) MXKAlert *mxNotification;
|
||||
@property (nonatomic) UIBackgroundTaskIdentifier bgTask;
|
||||
|
||||
@property (strong, nonatomic) NSMutableDictionary *partialTextMsgByRoomId;
|
||||
|
@ -424,18 +423,18 @@ static MatrixSDKHandler *sharedHandler = nil;
|
|||
NSString* messageText = [self displayTextForEvent:event withRoomState:roomState inSubtitleMode:YES];
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
self.mxNotification = [[MXCAlert alloc] initWithTitle:roomState.displayname
|
||||
self.mxNotification = [[MXKAlert alloc] initWithTitle:roomState.displayname
|
||||
message:messageText
|
||||
style:MXCAlertStyleAlert];
|
||||
style:MXKAlertStyleAlert];
|
||||
self.mxNotification.cancelButtonIndex = [self.mxNotification addActionWithTitle:@"Cancel"
|
||||
style:MXCAlertActionStyleDefault
|
||||
handler:^(MXCAlert *alert) {
|
||||
style:MXKAlertActionStyleDefault
|
||||
handler:^(MXKAlert *alert) {
|
||||
weakSelf.mxNotification = nil;
|
||||
[weakSelf.unnotifiedRooms addObject:event.roomId];
|
||||
}];
|
||||
[self.mxNotification addActionWithTitle:@"View"
|
||||
style:MXCAlertActionStyleDefault
|
||||
handler:^(MXCAlert *alert) {
|
||||
style:MXKAlertActionStyleDefault
|
||||
handler:^(MXKAlert *alert) {
|
||||
weakSelf.mxNotification = nil;
|
||||
// Show the room
|
||||
[[AppDelegate theDelegate].masterTabBarController showRoom:event.roomId];
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
#import "MasterTabBarController.h"
|
||||
#import "MXCAlert.h"
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate> {
|
||||
BOOL isAPNSRegistered;
|
||||
|
@ -26,7 +26,7 @@
|
|||
@property (strong, nonatomic) UIWindow *window;
|
||||
@property (strong, nonatomic) MasterTabBarController *masterTabBarController;
|
||||
|
||||
@property (strong, nonatomic) MXCAlert *errorNotification;
|
||||
@property (strong, nonatomic) MXKAlert *errorNotification;
|
||||
|
||||
@property (strong, nonatomic) NSString *appVersion;
|
||||
@property (strong, nonatomic) NSString *build;
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
- (void)logout;
|
||||
|
||||
- (MXCAlert*)showErrorAsAlert:(NSError*)error;
|
||||
- (MXKAlert*)showErrorAsAlert:(NSError*)error;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@
|
|||
[self.masterTabBarController setSelectedIndex:TABBAR_HOME_INDEX];
|
||||
}
|
||||
|
||||
- (MXCAlert*)showErrorAsAlert:(NSError*)error {
|
||||
- (MXKAlert*)showErrorAsAlert:(NSError*)error {
|
||||
// Ignore network reachability error when the app is already offline
|
||||
if (self.isOffline && [error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorNotConnectedToInternet) {
|
||||
return nil;
|
||||
|
@ -309,8 +309,8 @@
|
|||
}
|
||||
NSString *msg = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
|
||||
|
||||
self.errorNotification = [[MXCAlert alloc] initWithTitle:title message:msg style:MXCAlertStyleAlert];
|
||||
self.errorNotification.cancelButtonIndex = [self.errorNotification addActionWithTitle:@"OK" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
self.errorNotification = [[MXKAlert alloc] initWithTitle:title message:msg style:MXKAlertStyleAlert];
|
||||
self.errorNotification.cancelButtonIndex = [self.errorNotification addActionWithTitle:@"OK" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
[AppDelegate theDelegate].errorNotification = nil;
|
||||
}];
|
||||
[self.errorNotification showInViewController:[self.masterTabBarController selectedViewController]];
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
// Note: UIAlertView is deprecated in iOS 8. To create and manage alerts in iOS 8 and later, instead use UIAlertController
|
||||
// with a preferredStyle of UIAlertControllerStyleAlert.
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
MXCAlertActionStyleDefault = 0,
|
||||
MXCAlertActionStyleCancel,
|
||||
MXCAlertActionStyleDestructive
|
||||
} MXCAlertActionStyle;
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
MXCAlertStyleActionSheet = 0,
|
||||
MXCAlertStyleAlert
|
||||
} MXCAlertStyle;
|
||||
|
||||
@interface MXCAlert : NSObject <UIActionSheetDelegate> {
|
||||
}
|
||||
|
||||
typedef void (^blockMXCAlert_onClick)(MXCAlert *alert);
|
||||
typedef void (^blockMXCAlert_textFieldHandler)(UITextField *textField);
|
||||
|
||||
@property(nonatomic) NSInteger cancelButtonIndex; // required to dismiss cusmtomAlert on iOS < 8 (default is -1).
|
||||
@property(nonatomic, weak) UIView *sourceView;
|
||||
|
||||
- (id)initWithTitle:(NSString *)title message:(NSString *)message style:(MXCAlertStyle)style;
|
||||
// adds a button with the title. returns the index (0 based) of where it was added.
|
||||
- (NSInteger)addActionWithTitle:(NSString *)title style:(MXCAlertActionStyle)style handler:(blockMXCAlert_onClick)handler;
|
||||
// Adds a text field to an alert (Note: You can add a text field only if the style property is set to MXCAlertStyleAlert).
|
||||
- (void)addTextFieldWithConfigurationHandler:(blockMXCAlert_textFieldHandler)configurationHandler;
|
||||
|
||||
- (void)showInViewController:(UIViewController*)viewController;
|
||||
|
||||
- (void)dismiss:(BOOL)animated;
|
||||
- (UITextField *)textFieldAtIndex:(NSInteger)textFieldIndex;
|
||||
|
||||
@end
|
|
@ -1,232 +0,0 @@
|
|||
|
||||
/*
|
||||
Copyright 2014 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "MXCAlert.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@interface MXCAlert()
|
||||
{
|
||||
UIViewController* parentViewController;
|
||||
NSMutableArray *actions; // use only for iOS < 8
|
||||
}
|
||||
|
||||
@property(nonatomic, strong) id alert; // alert is kind of UIAlertController for IOS 8 and later, in other cases it's kind of UIAlertView or UIActionSheet.
|
||||
@end
|
||||
|
||||
@implementation MXCAlert
|
||||
|
||||
- (void)dealloc {
|
||||
// iOS < 8
|
||||
if ([_alert isKindOfClass:[UIActionSheet class]] || [_alert isKindOfClass:[UIAlertView class]]) {
|
||||
// Dismiss here AlertView or ActionSheet (if any) because its delegate is released
|
||||
[self dismiss:NO];
|
||||
}
|
||||
|
||||
_alert = nil;
|
||||
parentViewController = nil;
|
||||
actions = nil;
|
||||
}
|
||||
|
||||
- (id)initWithTitle:(NSString *)title message:(NSString *)message style:(MXCAlertStyle)style {
|
||||
if (self = [super init]) {
|
||||
// Check iOS version
|
||||
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) {
|
||||
_alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:(UIAlertControllerStyle)style];
|
||||
} else {
|
||||
// Use legacy objects
|
||||
if (style == MXCAlertStyleActionSheet) {
|
||||
_alert = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
|
||||
} else {
|
||||
_alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
|
||||
}
|
||||
|
||||
self.cancelButtonIndex = -1;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (NSInteger)addActionWithTitle:(NSString *)title style:(MXCAlertActionStyle)style handler:(blockMXCAlert_onClick)handler {
|
||||
NSInteger index = 0;
|
||||
if ([_alert isKindOfClass:[UIAlertController class]]) {
|
||||
index = [(UIAlertController *)_alert actions].count;
|
||||
UIAlertAction* action = [UIAlertAction actionWithTitle:title
|
||||
style:(UIAlertActionStyle)style
|
||||
handler:^(UIAlertAction * action) {
|
||||
if (handler) {
|
||||
handler(self);
|
||||
}
|
||||
}];
|
||||
|
||||
[(UIAlertController *)_alert addAction:action];
|
||||
} else if ([_alert isKindOfClass:[UIActionSheet class]]) {
|
||||
if (actions == nil) {
|
||||
actions = [NSMutableArray array];
|
||||
}
|
||||
index = [(UIActionSheet *)_alert addButtonWithTitle:title];
|
||||
if (handler) {
|
||||
[actions addObject:handler];
|
||||
} else {
|
||||
[actions addObject:[NSNull null]];
|
||||
}
|
||||
} else if ([_alert isKindOfClass:[UIAlertView class]]) {
|
||||
if (actions == nil) {
|
||||
actions = [NSMutableArray array];
|
||||
}
|
||||
index = [(UIAlertView *)_alert addButtonWithTitle:title];
|
||||
if (handler) {
|
||||
[actions addObject:handler];
|
||||
} else {
|
||||
[actions addObject:[NSNull null]];
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
- (void)addTextFieldWithConfigurationHandler:(blockMXCAlert_textFieldHandler)configurationHandler {
|
||||
if ([_alert isKindOfClass:[UIAlertController class]]) {
|
||||
[(UIAlertController *)_alert addTextFieldWithConfigurationHandler:configurationHandler];
|
||||
} else if ([_alert isKindOfClass:[UIAlertView class]]) {
|
||||
UIAlertView *alertView = (UIAlertView *)_alert;
|
||||
// Check the current style
|
||||
if (alertView.alertViewStyle == UIAlertViewStyleDefault) {
|
||||
// Add the first text fields
|
||||
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
|
||||
if (configurationHandler) {
|
||||
// Store the callback
|
||||
UITextField *textField = [alertView textFieldAtIndex:0];
|
||||
objc_setAssociatedObject(textField, "configurationHandler", [configurationHandler copy], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
} else if (alertView.alertViewStyle != UIAlertViewStyleLoginAndPasswordInput) {
|
||||
// Add a second text field
|
||||
alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
|
||||
|
||||
if (configurationHandler) {
|
||||
// Store the callback
|
||||
UITextField *textField = [alertView textFieldAtIndex:1];
|
||||
objc_setAssociatedObject(textField, "configurationHandler", [configurationHandler copy], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
}
|
||||
// CAUTION 1: only 2 text fields are supported fro iOS < 8
|
||||
// CAUTION 2: alert style "UIAlertViewStyleSecureTextInput" is not supported, use the configurationHandler to handle secure text field
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showInViewController:(UIViewController*)viewController {
|
||||
if ([_alert isKindOfClass:[UIAlertController class]]) {
|
||||
if (viewController) {
|
||||
parentViewController = viewController;
|
||||
if (self.sourceView) {
|
||||
[_alert popoverPresentationController].sourceView = self.sourceView;
|
||||
[_alert popoverPresentationController].sourceRect = self.sourceView.bounds;
|
||||
}
|
||||
[viewController presentViewController:(UIAlertController *)_alert animated:YES completion:nil];
|
||||
}
|
||||
} else if ([_alert isKindOfClass:[UIActionSheet class]]) {
|
||||
[(UIActionSheet *)_alert showInView:[[UIApplication sharedApplication] keyWindow]];
|
||||
} else if ([_alert isKindOfClass:[UIAlertView class]]) {
|
||||
UIAlertView *alertView = (UIAlertView *)_alert;
|
||||
if (alertView.alertViewStyle != UIAlertViewStyleDefault) {
|
||||
// Call here textField handlers
|
||||
UITextField *textField = [alertView textFieldAtIndex:0];
|
||||
blockMXCAlert_textFieldHandler configurationHandler = objc_getAssociatedObject(textField, "configurationHandler");
|
||||
if (configurationHandler) {
|
||||
configurationHandler (textField);
|
||||
}
|
||||
if (alertView.alertViewStyle == UIAlertViewStyleLoginAndPasswordInput) {
|
||||
textField = [alertView textFieldAtIndex:1];
|
||||
blockMXCAlert_textFieldHandler configurationHandler = objc_getAssociatedObject(textField, "configurationHandler");
|
||||
if (configurationHandler) {
|
||||
configurationHandler (textField);
|
||||
}
|
||||
}
|
||||
}
|
||||
[alertView show];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dismiss:(BOOL)animated {
|
||||
if ([_alert isKindOfClass:[UIAlertController class]]) {
|
||||
// only dismiss it if it is presented
|
||||
if (parentViewController.presentedViewController == _alert) {
|
||||
[parentViewController dismissViewControllerAnimated:animated completion:nil];
|
||||
}
|
||||
} else if ([_alert isKindOfClass:[UIActionSheet class]]) {
|
||||
[((UIActionSheet *)_alert) dismissWithClickedButtonIndex:self.cancelButtonIndex animated:animated];
|
||||
} else if ([_alert isKindOfClass:[UIAlertView class]]) {
|
||||
[((UIAlertView *)_alert) dismissWithClickedButtonIndex:self.cancelButtonIndex animated:animated];
|
||||
}
|
||||
_alert = nil;
|
||||
}
|
||||
|
||||
- (UITextField *)textFieldAtIndex:(NSInteger)textFieldIndex{
|
||||
if ([_alert isKindOfClass:[UIAlertController class]]) {
|
||||
return [((UIAlertController*)_alert).textFields objectAtIndex:textFieldIndex];
|
||||
} else if ([_alert isKindOfClass:[UIAlertView class]]) {
|
||||
return [((UIAlertView*)_alert) textFieldAtIndex:textFieldIndex];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - UIAlertViewDelegate (iOS < 8)
|
||||
|
||||
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
|
||||
// sanity check
|
||||
// the user could have forgotten to set the cancel button index
|
||||
if (buttonIndex < actions.count) {
|
||||
// Retrieve the callback
|
||||
blockMXCAlert_onClick block = [actions objectAtIndex:buttonIndex];
|
||||
if ([block isEqual:[NSNull null]] == NO) {
|
||||
// And call it
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
block(self);
|
||||
});
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Release alert reference
|
||||
_alert = nil;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UIActionSheetDelegate (iOS < 8)
|
||||
|
||||
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
|
||||
|
||||
// sanity check
|
||||
// the user could have forgotten to set the cancel button index
|
||||
if (buttonIndex < actions.count) {
|
||||
// Retrieve the callback
|
||||
blockMXCAlert_onClick block = [actions objectAtIndex:buttonIndex];
|
||||
if ([block isEqual:[NSNull null]] == NO) {
|
||||
// And call it
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
block(self);
|
||||
});
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Release _alert reference
|
||||
_alert = nil;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -19,13 +19,12 @@
|
|||
#import "RageShakableUIResponder.h"
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "MXCAlert.h"
|
||||
#import "MatrixSDKHandler.h"
|
||||
|
||||
#import "GBDeviceInfo_iOS.h"
|
||||
|
||||
@interface RageShakableUIResponder() {
|
||||
MXCAlert *confirmationAlert;
|
||||
MXKAlert *confirmationAlert;
|
||||
double startShakingTimeStamp;
|
||||
bool isShaking;
|
||||
bool ignoreShakeEnd;
|
||||
|
@ -85,13 +84,13 @@ static RageShakableUIResponder* sharedInstance = nil;
|
|||
rageShakableUIResponder->startShakingTimeStamp = [[NSDate date] timeIntervalSince1970];
|
||||
|
||||
if ([responder isKindOfClass:[UIViewController class]]) {
|
||||
rageShakableUIResponder->confirmationAlert = [[MXCAlert alloc] initWithTitle:@"You seem to be shaking the phone in frustration. Would you like to submit a bug report?" message:nil style:MXCAlertStyleAlert];
|
||||
rageShakableUIResponder->confirmationAlert = [[MXKAlert alloc] initWithTitle:@"You seem to be shaking the phone in frustration. Would you like to submit a bug report?" message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
[rageShakableUIResponder->confirmationAlert addActionWithTitle:@"Cancel" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[rageShakableUIResponder->confirmationAlert addActionWithTitle:@"Cancel" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
sharedInstance->confirmationAlert = nil;
|
||||
}];
|
||||
|
||||
[rageShakableUIResponder->confirmationAlert addActionWithTitle:@"OK" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[rageShakableUIResponder->confirmationAlert addActionWithTitle:@"OK" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
sharedInstance->confirmationAlert = nil;
|
||||
[RageShakableUIResponder sendEmail:(UIViewController*)responder withSnapshot:YES];
|
||||
}];
|
||||
|
@ -130,15 +129,15 @@ static RageShakableUIResponder* sharedInstance = nil;
|
|||
sharedInstance = [[RageShakableUIResponder alloc] init];
|
||||
}
|
||||
|
||||
sharedInstance->confirmationAlert = [[MXCAlert alloc] initWithTitle:@"The application has crashed last time. Would you like to submit a crash report?" message:nil style:MXCAlertStyleAlert];
|
||||
sharedInstance->confirmationAlert = [[MXKAlert alloc] initWithTitle:@"The application has crashed last time. Would you like to submit a crash report?" message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
[sharedInstance->confirmationAlert addActionWithTitle:@"Cancel" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[sharedInstance->confirmationAlert addActionWithTitle:@"Cancel" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
// Erase the crash log (there is only chance for the user to send it)
|
||||
[MXLogger deleteCrashLog];
|
||||
sharedInstance->confirmationAlert = nil;
|
||||
}];
|
||||
|
||||
[sharedInstance->confirmationAlert addActionWithTitle:@"OK" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[sharedInstance->confirmationAlert addActionWithTitle:@"OK" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
sharedInstance->confirmationAlert = nil;
|
||||
[RageShakableUIResponder sendEmail:viewController withSnapshot:NO];
|
||||
}];
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#import "MatrixSDKHandler.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "MXCAlert.h"
|
||||
#import "MXCRegistrationWebView.h"
|
||||
|
||||
@interface AuthenticationViewController () {
|
||||
|
@ -32,7 +31,7 @@
|
|||
AuthInputsView *currentAuthInputsView;
|
||||
|
||||
// reference to any opened alert view
|
||||
MXCAlert *alert;
|
||||
MXKAlert *alert;
|
||||
}
|
||||
|
||||
// Return true if the provided flow (kMXLoginFlowType) is supported by the application
|
||||
|
@ -326,8 +325,8 @@
|
|||
}
|
||||
NSString *msg = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
|
||||
|
||||
alert = [[MXCAlert alloc] initWithTitle:title message:msg style:MXCAlertStyleAlert];
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"Dismiss" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {}];
|
||||
alert = [[MXKAlert alloc] initWithTitle:title message:msg style:MXKAlertStyleAlert];
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"Dismiss" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {}];
|
||||
[alert showInViewController:self];
|
||||
|
||||
// Display failure reason
|
||||
|
@ -461,8 +460,8 @@
|
|||
}
|
||||
|
||||
//Alert user
|
||||
alert = [[MXCAlert alloc] initWithTitle:@"Login Failed" message:message style:MXCAlertStyleAlert];
|
||||
[alert addActionWithTitle:@"Dismiss" style:MXCAlertActionStyleCancel handler:^(MXCAlert *alert) {}];
|
||||
alert = [[MXKAlert alloc] initWithTitle:@"Login Failed" message:message style:MXKAlertStyleAlert];
|
||||
[alert addActionWithTitle:@"Dismiss" style:MXKAlertActionStyleCancel handler:^(MXKAlert *alert) {}];
|
||||
[alert showInViewController:self];
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
// contact cell
|
||||
#import "ContactTableCell.h"
|
||||
|
||||
// alert
|
||||
#import "MXCAlert.h"
|
||||
|
||||
// settings
|
||||
#import "AppSettings.h"
|
||||
|
||||
|
@ -66,8 +63,8 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
|
|||
NSString* latestSearchedPattern;
|
||||
}
|
||||
|
||||
@property (strong, nonatomic) MXCAlert *startChatMenu;
|
||||
@property (strong, nonatomic) MXCAlert *allowContactSyncAlert;
|
||||
@property (strong, nonatomic) MXKAlert *startChatMenu;
|
||||
@property (strong, nonatomic) MXKAlert *allowContactSyncAlert;
|
||||
@property (weak, nonatomic) IBOutlet UITableView* tableView;
|
||||
@property (weak, nonatomic) IBOutlet UISegmentedControl* contactsControls;
|
||||
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
|
||||
|
@ -432,29 +429,29 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
|
|||
if (matrixIDs.count == 1) {
|
||||
NSString* matrixID = [matrixIDs objectAtIndex:0];
|
||||
|
||||
self.startChatMenu = [[MXCAlert alloc] initWithTitle:[NSString stringWithFormat:@"Chat with %@", matrixID] message:nil style:MXCAlertStyleAlert];
|
||||
self.startChatMenu = [[MXKAlert alloc] initWithTitle:[NSString stringWithFormat:@"Chat with %@", matrixID] message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
[self.startChatMenu addActionWithTitle:@"Cancel" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.startChatMenu addActionWithTitle:@"Cancel" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.startChatMenu = nil;
|
||||
}];
|
||||
|
||||
[self.startChatMenu addActionWithTitle:@"OK" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.startChatMenu addActionWithTitle:@"OK" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.startChatMenu = nil;
|
||||
|
||||
[mxHandler startPrivateOneToOneRoomWithUserId:matrixID];
|
||||
}];
|
||||
} else {
|
||||
self.startChatMenu = [[MXCAlert alloc] initWithTitle:[NSString stringWithFormat:@"Chat with "] message:nil style:MXCAlertStyleActionSheet];
|
||||
self.startChatMenu = [[MXKAlert alloc] initWithTitle:[NSString stringWithFormat:@"Chat with "] message:nil style:MXKAlertStyleActionSheet];
|
||||
|
||||
for(NSString* matrixID in matrixIDs) {
|
||||
[self.startChatMenu addActionWithTitle:matrixID style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.startChatMenu addActionWithTitle:matrixID style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.startChatMenu = nil;
|
||||
|
||||
[mxHandler startPrivateOneToOneRoomWithUserId:matrixID];
|
||||
}];
|
||||
}
|
||||
|
||||
[self.startChatMenu addActionWithTitle:@"Cancel" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.startChatMenu addActionWithTitle:@"Cancel" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.startChatMenu = nil;
|
||||
}];
|
||||
|
||||
|
@ -468,14 +465,14 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
|
|||
// invite to use matrix
|
||||
if (([MFMessageComposeViewController canSendText] ? contact.emailAddresses.count : 0) + (contact.phoneNumbers.count > 0)) {
|
||||
|
||||
self.startChatMenu = [[MXCAlert alloc] initWithTitle:[NSString stringWithFormat:@"Invite this user to use matrix with"] message:nil style:MXCAlertStyleActionSheet];
|
||||
self.startChatMenu = [[MXKAlert alloc] initWithTitle:[NSString stringWithFormat:@"Invite this user to use matrix with"] message:nil style:MXKAlertStyleActionSheet];
|
||||
|
||||
// check if the target can send SMSes
|
||||
if ([MFMessageComposeViewController canSendText]) {
|
||||
// list phonenumbers
|
||||
for(MXCPhoneNumber* phonenumber in contact.phoneNumbers) {
|
||||
|
||||
[self.startChatMenu addActionWithTitle:phonenumber.textNumber style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.startChatMenu addActionWithTitle:phonenumber.textNumber style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.startChatMenu = nil;
|
||||
|
||||
// launch SMS composer
|
||||
|
@ -498,7 +495,7 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
|
|||
// list emails
|
||||
for(MXCEmail* email in contact.emailAddresses) {
|
||||
|
||||
[self.startChatMenu addActionWithTitle:email.emailAddress style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.startChatMenu addActionWithTitle:email.emailAddress style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.startChatMenu = nil;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
@ -511,7 +508,7 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
|
|||
}];
|
||||
}
|
||||
|
||||
[self.startChatMenu addActionWithTitle:@"Cancel" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.startChatMenu addActionWithTitle:@"Cancel" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.startChatMenu = nil;
|
||||
}];
|
||||
|
||||
|
@ -588,13 +585,13 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
|
|||
if (!appSettings.syncLocalContacts) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
self.allowContactSyncAlert = [[MXCAlert alloc] initWithTitle:@"Allow local contacts synchronization ?" message:nil style:MXCAlertStyleAlert];
|
||||
self.allowContactSyncAlert = [[MXKAlert alloc] initWithTitle:@"Allow local contacts synchronization ?" message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
[self.allowContactSyncAlert addActionWithTitle:@"No" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.allowContactSyncAlert addActionWithTitle:@"No" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.allowContactSyncAlert = nil;
|
||||
}];
|
||||
|
||||
[self.allowContactSyncAlert addActionWithTitle:@"Yes" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.allowContactSyncAlert addActionWithTitle:@"Yes" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.allowContactSyncAlert = nil;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
appSettings.syncLocalContacts = YES;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
@property (weak, nonatomic) IBOutlet UIButton *memberThumbnailButton;
|
||||
@property (weak, nonatomic) IBOutlet UITextView *roomMemberMID;
|
||||
|
||||
@property (strong, nonatomic) MXCAlert *actionMenu;
|
||||
@property (strong, nonatomic) MXKAlert *actionMenu;
|
||||
|
||||
- (IBAction)onButtonToggle:(id)sender;
|
||||
|
||||
|
@ -393,10 +393,10 @@
|
|||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
// Ask for userId to invite
|
||||
self.actionMenu = [[MXCAlert alloc] initWithTitle:@"Power Level" message:nil style:MXCAlertStyleAlert];
|
||||
self.actionMenu = [[MXKAlert alloc] initWithTitle:@"Power Level" message:nil style:MXKAlertStyleAlert];
|
||||
|
||||
if (![mxHandler.userId isEqualToString:roomMember.userId]) {
|
||||
self.actionMenu.cancelButtonIndex = [self.actionMenu addActionWithTitle:@"Reset to default" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
self.actionMenu.cancelButtonIndex = [self.actionMenu addActionWithTitle:@"Reset to default" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.actionMenu = nil;
|
||||
|
||||
[weakSelf setUserPowerLevel:roomMember to:0];
|
||||
|
@ -408,7 +408,7 @@
|
|||
textField.placeholder = nil;
|
||||
textField.keyboardType = UIKeyboardTypeDecimalPad;
|
||||
}];
|
||||
[self.actionMenu addActionWithTitle:@"OK" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[self.actionMenu addActionWithTitle:@"OK" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
UITextField *textField = [alert textFieldAtIndex:0];
|
||||
weakSelf.actionMenu = nil;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
@property (weak, nonatomic) IBOutlet UIView *membersView;
|
||||
@property (weak, nonatomic) IBOutlet UITableView *membersTableView;
|
||||
|
||||
@property (strong, nonatomic) MXCAlert *actionMenu;
|
||||
@property (strong, nonatomic) MXKAlert *actionMenu;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -544,8 +544,8 @@
|
|||
if (self.actionMenu) {
|
||||
[self.actionMenu dismiss:NO];
|
||||
}
|
||||
self.actionMenu = [[MXCAlert alloc] initWithTitle:nil message:alertMsg style:MXCAlertStyleAlert];
|
||||
self.actionMenu.cancelButtonIndex = [self.actionMenu addActionWithTitle:@"Cancel" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
self.actionMenu = [[MXKAlert alloc] initWithTitle:nil message:alertMsg style:MXKAlertStyleAlert];
|
||||
self.actionMenu.cancelButtonIndex = [self.actionMenu addActionWithTitle:@"Cancel" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
weakSelf.actionMenu = nil;
|
||||
}];
|
||||
[self.actionMenu showInViewController:self];
|
||||
|
|
|
@ -222,9 +222,9 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
// Check whether some local changes have not been saved
|
||||
if (_saveUserInfoButton.enabled) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
MXCAlert *alert = [[MXCAlert alloc] initWithTitle:nil message:@"Changes will be discarded" style:MXCAlertStyleAlert];
|
||||
MXKAlert *alert = [[MXKAlert alloc] initWithTitle:nil message:@"Changes will be discarded" style:MXKAlertStyleAlert];
|
||||
[alertsArray addObject:alert];
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"Discard" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"Discard" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
[alertsArray removeObject:alert];
|
||||
// Discard changes
|
||||
self.userDisplayName.text = currentDisplayName;
|
||||
|
@ -234,7 +234,7 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
handler();
|
||||
}
|
||||
}];
|
||||
[alert addActionWithTitle:@"Save" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[alert addActionWithTitle:@"Save" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
[alertsArray removeObject:alert];
|
||||
// Start saving
|
||||
[self saveUserInfo];
|
||||
|
@ -269,7 +269,7 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
}
|
||||
|
||||
// Cancel potential alerts
|
||||
for (MXCAlert *alert in alertsArray){
|
||||
for (MXKAlert *alert in alertsArray){
|
||||
[alert dismiss:NO];
|
||||
}
|
||||
|
||||
|
@ -406,9 +406,9 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
}
|
||||
NSString *msg = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
|
||||
|
||||
MXCAlert *alert = [[MXCAlert alloc] initWithTitle:title message:msg style:MXCAlertStyleAlert];
|
||||
MXKAlert *alert = [[MXKAlert alloc] initWithTitle:title message:msg style:MXKAlertStyleAlert];
|
||||
[alertsArray addObject:alert];
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"Abort" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"Abort" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
[alertsArray removeObject:alert];
|
||||
// Discard changes
|
||||
self.userDisplayName.text = currentDisplayName;
|
||||
|
@ -416,7 +416,7 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
// Loop to end saving
|
||||
[self saveUserInfo];
|
||||
}];
|
||||
[alert addActionWithTitle:@"Retry" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[alert addActionWithTitle:@"Retry" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
[alertsArray removeObject:alert];
|
||||
// Loop to retry saving
|
||||
[self saveUserInfo];
|
||||
|
@ -472,9 +472,9 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
}
|
||||
NSString *msg = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
|
||||
|
||||
MXCAlert *alert = [[MXCAlert alloc] initWithTitle:title message:msg style:MXCAlertStyleAlert];
|
||||
MXKAlert *alert = [[MXKAlert alloc] initWithTitle:title message:msg style:MXKAlertStyleAlert];
|
||||
[alertsArray addObject:alert];
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"Abort" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"Abort" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
[alertsArray removeObject:alert];
|
||||
// Remove change
|
||||
self.userDisplayName.text = currentDisplayName;
|
||||
|
@ -482,7 +482,7 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
// Loop to end saving
|
||||
[self saveUserInfo];
|
||||
}];
|
||||
[alert addActionWithTitle:@"Retry" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
[alert addActionWithTitle:@"Retry" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
[alertsArray removeObject:alert];
|
||||
// Loop to retry saving
|
||||
[self saveUserInfo];
|
||||
|
@ -654,9 +654,9 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
}];
|
||||
} else {
|
||||
NSLog(@"[SettingsVC] Failed to link email");
|
||||
MXCAlert *alert = [[MXCAlert alloc] initWithTitle:nil message:@"Failed to link email" style:MXCAlertStyleAlert];
|
||||
MXKAlert *alert = [[MXKAlert alloc] initWithTitle:nil message:@"Failed to link email" style:MXKAlertStyleAlert];
|
||||
[alertsArray addObject:alert];
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"OK" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
|
||||
alert.cancelButtonIndex = [alert addActionWithTitle:@"OK" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
[alertsArray removeObject:alert];
|
||||
}];
|
||||
[alert showInViewController:self];
|
||||
|
|
Loading…
Reference in a new issue