liuzhenxing1118 1 жил өмнө
parent
commit
14db0b6658

+ 0 - 4
artimenring-iOS/Artimenring/AppDelegate.h

@@ -13,9 +13,5 @@
 
 @property(nonatomic, strong) UIWindow *window;
 
-+ (AppDelegate*)appDelegate;
-+ (void)closeKeyWindow;
-
-
 @end
 

+ 13 - 32
artimenring-iOS/Artimenring/AppDelegate.m

@@ -66,26 +66,17 @@
     [FIRApp configure];
     [FIRMessaging messaging].delegate = self;
     
-    if ([UNUserNotificationCenter class] != nil) {
-        // iOS 10 or later
-        // For iOS 10 display notification (sent via APNS)
-        [UNUserNotificationCenter currentNotificationCenter].delegate = self;
-        UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
-        UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
-        [[UNUserNotificationCenter currentNotificationCenter]
-         requestAuthorizationWithOptions:authOptions
-         completionHandler:^(BOOL granted, NSError * _Nullable error) {
-             // ...
-         }];
-    } else {
-        // iOS 10 notifications aren't available; fall back to iOS 8-9 notifications.
-        UIUserNotificationType allNotificationTypes =
-        (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
-        UIUserNotificationSettings *settings =
-        [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
-        [application registerUserNotificationSettings:settings];
-    }
     
+    
+    [UNUserNotificationCenter currentNotificationCenter].delegate = self;
+    UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
+        UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
+    [[UNUserNotificationCenter currentNotificationCenter]
+        requestAuthorizationWithOptions:authOptions
+        completionHandler:^(BOOL granted, NSError * _Nullable error) {
+          // ...
+        }];
+
     [application registerForRemoteNotifications];
     
     
@@ -124,8 +115,8 @@
     }
     
     
-    [AppDelegate appDelegate].window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
-    [AppDelegate appDelegate].window.backgroundColor = [UIColor whiteColor];
+    [[UIApplication sharedApplication] delegate].window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+    [[UIApplication sharedApplication] delegate].window.backgroundColor = [UIColor whiteColor];
     
     
     NSDictionary* loginData = [UserDataHelper getLastLoginInfo];
@@ -138,7 +129,7 @@
         [[DataManager shared] showLoginViewController];
     }
     
-    [[AppDelegate appDelegate].window makeKeyAndVisible];
+    [[[UIApplication sharedApplication] delegate].window makeKeyAndVisible];
     
     return YES;
 }
@@ -257,16 +248,6 @@
     // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
 }
 
-+ (AppDelegate*)appDelegate
-{
-    return (AppDelegate*)[[UIApplication sharedApplication] delegate];
-}
-
-+ (void)closeKeyWindow
-{
-    [[UIApplication sharedApplication].keyWindow endEditing:YES];
-}
-
 // [START ios_10_message_handling]
 // Receive displayed notifications for iOS 10 devices.
 #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0

+ 1 - 1
artimenring-iOS/Artimenring/Classes/Chat/ZSChat/ZSChatOperationView.m

@@ -335,7 +335,7 @@
 
 - (void)failRecord {
     [ZSChatRecordView dismissWithSuccess:NSLocalizedString(@"Chat.Too.Short", nil)];
-    [EUtil showLongToastWithTitle:NSLocalizedString(@"Chat.Too.Short", nil)];
+    [EasyTextView showErrorText:NSLocalizedString(@"Chat.Too.Short", nil)];
     
     //缓冲消失时间 (最好有block回调消失完成)
     self.btnVoiceRecord.enabled = NO;

+ 3 - 3
artimenring-iOS/Artimenring/Classes/Data/DataManager.m

@@ -53,21 +53,21 @@
 
 - (void)showTabBarController {
     TabbarViewController* nav = [[TabbarViewController alloc] init];
-    [[AppDelegate appDelegate].window setRootViewController:nav];
+    [[[UIApplication sharedApplication] delegate].window setRootViewController:nav];
 }
 
 - (void)showLoginViewController {
     UIStoryboard *board = [UIStoryboard storyboardWithName:@"Login" bundle:nil];
     UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"LoginVC"];
     UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:vc];
-    [[AppDelegate appDelegate].window setRootViewController:nav];
+    [[[UIApplication sharedApplication] delegate].window setRootViewController:nav];
 }
 
 - (void)showScanImeiViewController {
     UIStoryboard *board = [UIStoryboard storyboardWithName:@"BindDevice" bundle:nil];
     UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"ScanImeiVC"];
     UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:vc];
-    [[AppDelegate appDelegate].window setRootViewController:nav];
+    [[[UIApplication sharedApplication] delegate].window setRootViewController:nav];
 }
 
 - (BOOL)isRootTabBarController {

+ 0 - 10
artimenring-iOS/Artimenring/Classes/Util/EUtil.h

@@ -23,16 +23,6 @@
  */
 + (BOOL)isNotNetWorking;
 
-/*!
- @brief 显示吐司
- @param titleStr 显示的吐司内容
- */
-+ (void)showToastWithTitle:(NSString *)titleStr;
-
-+ (void)showToastWithTitle:(NSString *)titleStr onComplete:(void(^)())onComplete;
-
-+ (void)showLongToastWithTitle:(NSString *)titleStr;
-
 /** 发送消息 */
 + (void)postInformation:(NSString *)name;
 

+ 0 - 149
artimenring-iOS/Artimenring/Classes/Util/EUtil.mm

@@ -37,155 +37,6 @@
     return YES;
 }
 
-+ (void)showToastWithTitle:(NSString *)titleStr onComplete:(void(^)())onComplete
-{
-    UIView *toastView = [[UIView alloc] initWithFrame:kFrame(0, 0, 260.f, 21.f)];
-    UILabel *titleLabel = [[UILabel alloc] initWithFrame:kFrame(0, 0, 200, 21.f)];
-    
-    UIView *bgView = [[UIView alloc] initWithFrame:toastView.bounds];
-    [bgView setBackgroundColor:kCOLOR(blackColor)];
-    [bgView setAlpha:0.4];
-    [toastView addSubview:bgView];
-    
-    [titleLabel setBackgroundColor:kCOLOR(clearColor)];
-    [titleLabel setTextColor:kCOLOR(whiteColor)];
-    [titleLabel setFont:kFONT(13.f)];
-    [titleLabel setText:titleStr];
-    [titleLabel setTextAlignment:NSTextAlignmentCenter];
-    [titleLabel setCenter:toastView.center];
-    [toastView addSubview:titleLabel];
-    
-    [toastView setBackgroundColor:kCOLOR(clearColor)];
-    [toastView.layer setMasksToBounds:YES];
-    [toastView.layer setCornerRadius:3];
-    [toastView setCenter:kPoint(160.f, -20)];
-    [[AppDelegate appDelegate].window addSubview:toastView];
-    
-    [UIView animateWithDuration:0.5 animations:^{
-        [toastView setBottom:58];
-    } completion:^(BOOL finished) {
-        double delayInSeconds = 1.0;
-        dispatch_time_t delayInNanoSeconds =dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
-        dispatch_queue_t concurrentQueue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-        dispatch_after(delayInNanoSeconds, concurrentQueue, ^(void){
-            dispatch_async(dispatch_get_main_queue(), ^{
-                [UIView animateWithDuration:0.35 animations:^{
-                    [toastView setTop:-20];
-                } completion:^(BOOL finished) {
-                    [toastView removeFromSuperview];
-                    onComplete();
-                }];
-            });
-        });
-    }];
-}
-
-static NSString* toastTitleStr = @"";
-+ (void)showToastWithTitle:(NSString *)titleStr
-{
-    //如果相同,则不显示
-    if ([toastTitleStr isEqualToString:titleStr])
-        return;
-    
-    toastTitleStr = titleStr;
-    
-    CGRect rect = [UIScreen mainScreen].bounds;
-    CGFloat winWidth = rect.size.width;
-    
-    UIView *toastView = [[UIView alloc] initWithFrame:kFrame(0, 0, winWidth-30, 21.f)];
-    UILabel *titleLabel = [[UILabel alloc] initWithFrame:kFrame(0, 0, winWidth-30*2, 21.f)];
-    
-    UIView *bgView = [[UIView alloc] initWithFrame:toastView.bounds];
-    [bgView setBackgroundColor:kCOLOR(blackColor)];
-    [bgView setAlpha:0.4];
-    [toastView addSubview:bgView];
-    
-    [titleLabel setBackgroundColor:kCOLOR(clearColor)];
-    [titleLabel setTextColor:kCOLOR(whiteColor)];
-    [titleLabel setFont:kFONT(13.f)];
-    [titleLabel setText:titleStr];
-    [titleLabel setTextAlignment:NSTextAlignmentCenter];
-    [titleLabel setCenter:toastView.center];
-    [toastView addSubview:titleLabel];
-    
-    [toastView setBackgroundColor:kCOLOR(clearColor)];
-    [toastView.layer setMasksToBounds:YES];
-    [toastView.layer setCornerRadius:3];
-    [toastView setCenter:kPoint([AppDelegate appDelegate].window.center.x, -20)];
-    [[AppDelegate appDelegate].window addSubview:toastView];
-    
-    [UIView animateWithDuration:0.5 animations:^{
-        [toastView setBottom:58];
-    } completion:^(BOOL finished) {
-        double delayInSeconds = 1.0;
-        dispatch_time_t delayInNanoSeconds =dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
-        dispatch_queue_t concurrentQueue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-        dispatch_after(delayInNanoSeconds, concurrentQueue, ^(void){
-            dispatch_async(dispatch_get_main_queue(), ^{
-                [UIView animateWithDuration:0.35 animations:^{
-                    [toastView setTop:-20];
-                } completion:^(BOOL finished) {
-                    [toastView removeFromSuperview];
-                    toastTitleStr = @"";
-                }];
-            });
-        });
-    }];    
-}
-
-+ (void)showLongToastWithTitle:(NSString *)titleStr
-{
-    //如果相同,则不显示
-    if ([toastTitleStr isEqualToString:titleStr])
-        return;
-    
-    toastTitleStr = titleStr;
-    
-    CGRect rect = [UIScreen mainScreen].bounds;
-    CGFloat winWidth = rect.size.width;
-    
-    UIView *toastView = [[UIView alloc] initWithFrame:kFrame(0, 0, winWidth-30, 21.f)];
-    UILabel *titleLabel = [[UILabel alloc] initWithFrame:kFrame(0, 0, winWidth-30*2, 21.f)];
-    
-    UIView *bgView = [[UIView alloc] initWithFrame:toastView.bounds];
-    [bgView setBackgroundColor:kCOLOR(blackColor)];
-    [bgView setAlpha:0.4];
-    [toastView addSubview:bgView];
-    
-    [titleLabel setBackgroundColor:kCOLOR(clearColor)];
-    [titleLabel setTextColor:kCOLOR(whiteColor)];
-    [titleLabel setFont:kFONT(13.f)];
-    titleLabel.adjustsFontSizeToFitWidth = YES;
-    [titleLabel setText:titleStr];
-    [titleLabel setTextAlignment:NSTextAlignmentCenter];
-    [titleLabel setCenter:toastView.center];
-    [toastView addSubview:titleLabel];
-    
-    [toastView setBackgroundColor:kCOLOR(clearColor)];
-    [toastView.layer setMasksToBounds:YES];
-    [toastView.layer setCornerRadius:3];
-    [toastView setCenter:kPoint([AppDelegate appDelegate].window.center.x, -20)];
-    [[AppDelegate appDelegate].window addSubview:toastView];
-    
-    [UIView animateWithDuration:0.5 animations:^{
-        [toastView setBottom:58];
-    } completion:^(BOOL finished) {
-        double delayInSeconds = 3.0;
-        dispatch_time_t delayInNanoSeconds =dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
-        dispatch_queue_t concurrentQueue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-        dispatch_after(delayInNanoSeconds, concurrentQueue, ^(void){
-            dispatch_async(dispatch_get_main_queue(), ^{
-                [UIView animateWithDuration:0.35 animations:^{
-                    [toastView setTop:-20];
-                } completion:^(BOOL finished) {
-                    [toastView removeFromSuperview];
-                    toastTitleStr = @"";
-                }];
-            });
-        });
-    }];
-}
-
 + (void)postInformation:(NSString *)name
 {
     [[NSNotificationCenter defaultCenter] postNotificationName:name object:nil];

+ 1 - 1
artimenring-iOS/Artimenring/Classes/View/SetFamilyTableViewCell.m

@@ -18,7 +18,7 @@
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated
 {
     [super setSelected:selected animated:animated];
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
 }
 
 - (void)configCell:(NSString *)mPhone index:(NSInteger)mCurrent

+ 1 - 1
artimenring-iOS/Artimenring/Classes/ViewController/Base/EBaseViewController.m

@@ -113,7 +113,7 @@
 
 
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
 }
 
 - (void)createView {

+ 3 - 3
artimenring-iOS/Artimenring/Classes/ViewController/Login/LoginPhoneNumberViewController.m

@@ -125,7 +125,7 @@
 #pragma mark - 注册
 - (IBAction)bindSimAction:(UIButton *)sender
 {
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
     
     if ([self checkRequestValue]) {
         
@@ -136,7 +136,7 @@
 #pragma mark - 获取短信验证码
 - (IBAction)getSecurityAction:(UIButton *)sender
 {
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
     
     if (![mMobileTextField.text isValidateMobile]) {
         [EasyTextView showInfoText:NSLocalizedString(@"Input.Correct.Mobile.Number", nil)];//@"请输入3~32位数字号码"];
@@ -174,7 +174,7 @@
         [mCodeTextField becomeFirstResponder];
     }else if(textField == mCodeTextField)
     {
-        [AppDelegate closeKeyWindow];
+        [[UIApplication sharedApplication].keyWindow endEditing:YES];
     }
     return YES;
 }

+ 4 - 4
artimenring-iOS/Artimenring/Classes/ViewController/Login/LoginViewController.m

@@ -69,7 +69,7 @@
     [self.navigationController setNavigationBarHidden:YES];
     
     //防止自动登陆时,联网屏蔽界面,但是未知原因,退出到登陆界面,导致屏幕不能点击问题//
-    [[AppDelegate appDelegate].window setUserInteractionEnabled:YES];
+    [[[UIApplication sharedApplication] delegate].window setUserInteractionEnabled:YES];
     
     if([EUtil getShowGuideKey] == nil)
         [self createGuideView];
@@ -211,7 +211,7 @@
     if (textField == usernameText) {
         [pwdText becomeFirstResponder];
     }else{
-        [AppDelegate closeKeyWindow];
+        [[UIApplication sharedApplication].keyWindow endEditing:YES];
     }
     return YES;
 }
@@ -232,7 +232,7 @@
 }
 
 - (IBAction)hidenKeyBoard:(id)sender{
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
 }
 
 #pragma mark - facebook
@@ -324,7 +324,7 @@ dismissViewController:(UIViewController *)viewController {
 }
 
 - (IBAction)logInAction:(UIButton *)sender {
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
     if ([self checkRequestValue]) {
         [self loginRequest];
     }

+ 1 - 1
artimenring-iOS/Artimenring/Classes/ViewController/Login/ModifyPasswordViewController.m

@@ -89,7 +89,7 @@
 
 - (IBAction)onClickConfirmModifyPassword:(id)sender {
     
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
     
     if(![self checkRequestValue])
         return;

+ 5 - 5
artimenring-iOS/Artimenring/Classes/ViewController/Login/RegisterViewController.m

@@ -176,7 +176,7 @@
 #pragma mark - 注册
 - (IBAction)registerAction:(UIButton *)sender
 {
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
     
     if ([self checkRequestValue]) {
         
@@ -205,7 +205,7 @@
 #pragma mark - 获取短信验证码
 - (IBAction)getSecurityAction:(UIButton *)sender
 {
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
     
     if (![mMobileTextField.text isValidateMobile]) {
         [EasyTextView showInfoText:NSLocalizedString(@"Input.Correct.Mobile.Number", nil)];//@"请输入3~32位数字号码"];
@@ -232,7 +232,7 @@
 #pragma mark - 同意条款
 - (IBAction)agreeAction:(UIButton *)sender
 {
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
     BOOL status = !sender.selected;
     [self setAgree:status];
     [sender setSelected:status];
@@ -240,7 +240,7 @@
 
 #pragma mark - 隐藏键盘
 - (IBAction)hidenKeyBoard:(id)sender{
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
 }
 
 #pragma mark - 返回
@@ -284,7 +284,7 @@
         [mCodeTextField becomeFirstResponder];
     }else if(textField == mCodeTextField)
     {
-        [AppDelegate closeKeyWindow];
+        [[UIApplication sharedApplication].keyWindow endEditing:YES];
     }
     return YES;
 }

+ 1 - 1
artimenring-iOS/Artimenring/Classes/ViewController/Login/ResetPassWordViewController.m

@@ -98,7 +98,7 @@
 
 - (IBAction)confirmAction:(id)sender{
     
-    [AppDelegate closeKeyWindow];
+    [[UIApplication sharedApplication].keyWindow endEditing:YES];
     
     if ([self checkInput] == NO)
         return;