From ea7dfe09eaed6edbebca1d2d89a135fc0c81695e Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 10 七月 2020 16:40:13 +0800
Subject: [PATCH] 2020-07-10 1.修改UI布局。

---
 xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m |   93 +++++++++++++++++++++++++++++++---------------
 1 files changed, 62 insertions(+), 31 deletions(-)

diff --git a/xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m b/xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m
index 63df999..8c073d9 100644
--- a/xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m
+++ b/xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m
@@ -14,7 +14,7 @@
 #import "AudioSessionHelper.h"
 #import <Photos/Photos.h>
 #import <AudioToolbox/AudioToolbox.h>
-
+#import "ESVideo.h"
 
 
 
@@ -80,6 +80,8 @@
     NSString * refuseStr;
     NSString * answerStr;
     NSString * unlockSuccessfullyStr;
+    NSString * callingStr;
+    NSString * hangUpStr;
     //    int openDoorTimeout;
     //鍏ㄥ眬鍙橀噺
     SystemSoundID sound;
@@ -92,11 +94,11 @@
     [self initTopBarView];
     [self initCentetView];
     [self initData];
-//    [self setAnswerBtnEnable:NO];
+    //    [self setAnswerBtnEnable:NO];
     [self initESVideo];
     //寮�濮嬪弽鍛�
     [self StartReverseCall];
-    [self ShowCalltimeBtn:@"瀹ゅ鏈烘潵鐢典腑..."];
+    [self ShowCalltimeBtn:callingStr];
     // Do any additional setup after loading the view.
 }
 
@@ -112,7 +114,9 @@
         operationFailedStr = @"鎿嶄綔澶辫触";
         refuseStr = @"鎷掔粷";
         answerStr = @"鎺ュ惉";
+        hangUpStr = @"鎸傛柇";
         unlockSuccessfullyStr = @"寮�閿佹垚鍔�";
+        callingStr = @"鏉ョ數涓�...";
     }else{
         tipStr = @"Prompt";
         okStr = @"OK";
@@ -120,7 +124,10 @@
         operationFailedStr = @"Operation failed.";
         refuseStr = @"Refuse";
         answerStr = @"Answer";
+        hangUpStr = @"Hang up";
         unlockSuccessfullyStr = @"Unlock successfully";
+        callingStr = @"Incoming call";
+        
     }
 }
 
@@ -152,8 +159,8 @@
 
 -(void)backAction{
     [self.navigationController popViewControllerAnimated:true];
-//    [self dismissViewControllerAnimated:YES completion:NULL];
- 
+    //    [self dismissViewControllerAnimated:YES completion:NULL];
+    
 }
 
 - (UIButton *)moreButton{
@@ -174,7 +181,7 @@
 
 - (void)initCentetView {
     [self.view addSubview:self.centerView];
-    [self.centerView addSubview:self.collectButton];
+    //    [self.centerView addSubview:self.collectButton];
     [self.centerView addSubview:self.homeView];
     [self.centerView addSubview:self.unlockView];
     [self.unlockView addSubview:self.screenshotImgBtn];
@@ -192,7 +199,7 @@
         _centerView.backgroundColor = UIColor.whiteColor;
         [self setRadiusWithView:_centerView];
         
-        _topUILabel= [[UILabel alloc] initWithFrame:CGRectMake(80, 20, APP_SCREEN_WIDTH-160, 24)];
+        _topUILabel= [[UILabel alloc] initWithFrame:CGRectMake(80, GetRealHeight(20), APP_SCREEN_WIDTH-160, GetRealHeight(24))];
         _topUILabel.font = [UIFont fontWithName:APP_UIFont_BOLD size:15.0];
         _topUILabel.textColor = HEXCOLORA(0x333333, 1.0);
         _topUILabel.text = @"浜屾纭鏈�";
@@ -241,9 +248,9 @@
 
 - (UIView *)homeView{
     if (_homeView == nil) {
-        _homeView = [[UIView alloc] initWithFrame:CGRectMake(0, 268, APP_SCREEN_WIDTH, 36)];
+        _homeView = [[UIView alloc] initWithFrame:CGRectMake(0, GetRealHeight(268), APP_SCREEN_WIDTH, GetRealHeight(36))];
         _homeView.backgroundColor = HEXCOLORA(0x232323, 1.0);
-        UIImageView *mUIImageView= [[UIImageView alloc] initWithFrame:CGRectMake(20, 4, 28, 28)];
+        UIImageView *mUIImageView= [[UIImageView alloc] initWithFrame:CGRectMake(GetRealWidth(20), GetRealHeight(4), GetRealHeight(28), GetRealHeight(28))];
         mUIImageView.image = [UIImage imageNamed:@"ic_esvideo_home"];
         [mUIImageView setContentMode:UIViewContentModeScaleAspectFit];
         [_homeView addSubview:mUIImageView];
@@ -254,7 +261,7 @@
 
 - (UILabel *)homeUILabel{
     if (_homeUILabel == nil) {
-        _homeUILabel = [[UILabel alloc] initWithFrame:CGRectMake(52, 8, APP_SCREEN_WIDTH - 100, 20)];
+        _homeUILabel = [[UILabel alloc] initWithFrame:CGRectMake(GetRealWidth(52), 0, APP_SCREEN_WIDTH - GetRealWidth(100), _homeView.frame.size.height)];
         _homeUILabel.font = [UIFont fontWithName:APP_UIFont size:12.0];
         _homeUILabel.textColor = [UIColor whiteColor];
         _homeUILabel.text = @"1鏍�203";
@@ -265,7 +272,7 @@
 
 - (UIView *)unlockView{
     if (_unlockView == nil) {
-        _unlockView = [[UIView alloc] initWithFrame:CGRectMake(0, 304, APP_SCREEN_WIDTH, 48)];
+        _unlockView = [[UIView alloc] initWithFrame:CGRectMake(0, GetRealHeight(304), APP_SCREEN_WIDTH, GetRealHeight(48))];
         _unlockView.backgroundColor = HEXCOLORA(0x232323, 1.0);
         _unlockView.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor;
         _unlockView.layer.shadowColor = [UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:0.4].CGColor;
@@ -278,7 +285,7 @@
 
 - (UIButton *)screenshotImgBtn{
     if (_screenshotImgBtn == nil) {
-        _screenshotImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(65, 6, 36, 36)];
+        _screenshotImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(GetRealWidth(65), GetRealHeight(6), GetRealHeight(36), GetRealHeight(36))];
         [_screenshotImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_takephoto_unselect"] forState:UIControlStateNormal];
         //        [_screenshotImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_takephoto_select"] forState:UIControlStateSelected];
         [_screenshotImgBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
@@ -303,7 +310,7 @@
 
 - (UIButton *)unlockImgBtn{
     if (_unlockImgBtn == nil) {
-        _unlockImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(274, 6, 36, 36)];
+        _unlockImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(APP_CONTENT_WIDTH-GetRealWidth(65)-GetRealHeight(36), GetRealHeight(6), GetRealHeight(36), GetRealHeight(36))];
         [_unlockImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_unlock_unselect"] forState:UIControlStateNormal];
         //        [_unlockImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_unlock_select"] forState:UIControlStateSelected];
         [_unlockImgBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
@@ -331,7 +338,7 @@
 #pragma 鎸傛柇鍜屽紑閿�
 - (UIButton *)hangUpImgBtn{
     if (_hangUpImgBtn == nil) {
-        _hangUpImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(54, 448, 58, 58)];
+        _hangUpImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(GetRealWidth(54), GetRealHeight(448), GetRealHeight(58), GetRealHeight(58))];
         [_hangUpImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_hangup"] forState:UIControlStateNormal];
         //        [_hangUpImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_hangup"] forState:UIControlStateSelected];
         [_hangUpImgBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
@@ -347,20 +354,22 @@
 
 - (UIButton *)hangUpTextBtn{
     if (_hangUpTextBtn == nil) {
-        _hangUpTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(33, 514, 100, 21)];
+        _hangUpTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(33, 514, GetRealWidth(100), GetRealHeight(21))];
         [_hangUpTextBtn setTitle:@"鎷掔粷" forState:UIControlStateNormal];
         _hangUpTextBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
         _hangUpTextBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:15.0];
         [_hangUpTextBtn setTitleColor:TextColor forState:UIControlStateNormal];
         [_hangUpTextBtn setTitleColor:TextSelectColor forState:UIControlStateSelected];
         [_hangUpTextBtn addTarget:self action:@selector(screenshotAction) forControlEvents:UIControlEventTouchUpInside];
+        _hangUpTextBtn.center = CGPointMake(_hangUpImgBtn.center.x, GetRealHeight(525));
+        
     }
     return _hangUpTextBtn;
 }
 
 - (UIButton *)answerImgBtn{
     if (_answerImgBtn == nil) {
-        _answerImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(263, 448, 58, 58)];
+        _answerImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(APP_CONTENT_WIDTH-GetRealWidth(54)-GetRealHeight(58), GetRealHeight(448), GetRealHeight(58), GetRealHeight(58))];
         [_answerImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_answer"] forState:UIControlStateNormal];
         //        [_answerImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_answer"] forState:UIControlStateSelected];
         [_answerImgBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
@@ -382,9 +391,12 @@
     _answerTextBtn.hidden = YES;
     
     //鎸傛柇鎸夐挳绉诲姩涓棿
-    _hangUpImgBtn.frame = CGRectMake(159, 448, 58, 58);
-    _hangUpTextBtn.frame = CGRectMake(138, 514, 100, 21);
+    //    _hangUpImgBtn.frame = CGRectMake(159, 448, 58, 58);
+    //    _hangUpTextBtn.frame = CGRectMake(138, 514, 100, 21);
+    _hangUpImgBtn.center = CGPointMake(APP_CONTENT_WIDTH/2, _hangUpImgBtn.center.y);
+    _hangUpTextBtn.center = CGPointMake(APP_CONTENT_WIDTH/2, _hangUpTextBtn.center.y);
     
+    [_hangUpTextBtn setTitle:hangUpStr forState:UIControlStateNormal];
     //寮�濮嬭鏃�
     _callTimeout = 0;
     [self startCountdown];
@@ -398,7 +410,7 @@
 
 - (UIButton *)answerTextBtn{
     if (_answerTextBtn == nil) {
-        _answerTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(242, 514, 100, 21)];
+        _answerTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(242, 514, GetRealWidth(100), GetRealHeight(21))];
         [_answerTextBtn setTitle:@"鎺ュ惉" forState:UIControlStateNormal];
         _answerTextBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:15.0];
         _answerTextBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
@@ -407,21 +419,22 @@
         [_answerTextBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
         [_answerTextBtn setTitleColor:TextSelectColor forState:UIControlStateSelected];
         [_answerTextBtn addTarget:self action:@selector(unlockAction) forControlEvents:UIControlEventTouchUpInside];
+        _answerTextBtn.center = CGPointMake(_answerImgBtn.center.x, GetRealHeight(525));
     }
     return _answerTextBtn;
 }
 
 - (UIButton *)calltimeBtn{
     if (_calltimeBtn == nil) {
-        _calltimeBtn = [[UIButton alloc] initWithFrame:CGRectMake(242, 382, 100, 30)];
+        _calltimeBtn = [[UIButton alloc] initWithFrame:CGRectMake(242, GetRealHeight(382), GetRealWidth(100), GetRealHeight(30))];
         _calltimeBtn.backgroundColor = HEXCOLORA(0x000000, 0.4);
         [_calltimeBtn setTitle:@"00:00" forState:UIControlStateNormal];
         _calltimeBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:14.0];
         _calltimeBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
         [_calltimeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
-        _calltimeBtn.center = CGPointMake(APP_SCREEN_WIDTH/2, 397);
         _calltimeBtn.hidden = YES;
         _calltimeBtn.layer.cornerRadius = 15;
+        _calltimeBtn.center = CGPointMake(APP_CONTENT_WIDTH/2, GetRealHeight(397));
     }
     return _calltimeBtn;
 }
@@ -437,9 +450,9 @@
 
 -(void)ShowCalltimeBtn:(NSString*) mesStr  {
     if(_calltimeBtn.hidden) _calltimeBtn.hidden = NO;
-
+    
     [self setCalltimeButtonText:mesStr isTime:NO];
-
+    
     
 }
 
@@ -450,11 +463,11 @@
 {
     [_calltimeBtn setTitle:mesStr forState:UIControlStateNormal];
     if(isTime){
-        _calltimeBtn.frame = CGRectMake(0, 0, 100, 30);
+        _calltimeBtn.frame = CGRectMake(0, 0, GetRealWidth(80), GetRealHeight(30));
     }else{
-        _calltimeBtn.frame = CGRectMake(0, 0, 150, 30);
+        _calltimeBtn.frame = CGRectMake(0, 0, GetRealWidth(115), GetRealHeight(30));
     }
-    _calltimeBtn.center = CGPointMake(APP_SCREEN_WIDTH/2, 397);
+    _calltimeBtn.center = CGPointMake(APP_SCREEN_WIDTH/2, GetRealHeight(397));
 }
 
 
@@ -575,7 +588,10 @@
 
 #pragma SDK鍙瀵硅 鍔熻兘閮ㄥ垎
 -(void)initESVideo{
+    _es = ESVideo.shareInstance.es;
     //鍒濆鍖栦腑鏂紝杩涘叆鍚庡彴鐨則ag
+    
+    
     _playing = NO;
     _isSpeaking = NO;
     self.isInterrupt = NO;
@@ -593,13 +609,15 @@
             });
         };
         //闂ㄥ彛鏈轰細鏈夎棰戠殑闀垮楂橈紝鏄浐瀹氱殑锛堟殏鏃惰繕涓嶇‘瀹氾級
-        _es = [[ESVideoPhone alloc]initESVideoPhoneWithFrame:CGRectMake(0, 57, APP_SCREEN_WIDTH, 211) delegate:self imagecallBack:snapImageCallback];
+        //        _es = [[ESVideoPhone alloc]initESVideoPhoneWithFrame:CGRectMake(0, 57, APP_SCREEN_WIDTH, 211) delegate:self imagecallBack:snapImageCallback];
         if (_es) {
             //鍒ゆ柇瑙嗛娓叉煋鏄惁鍒濆鍖栨垚鍔燂紝濡傛灉澶辫触浼氳蛋ESVideoPhoneDelegate鏂规硶
             if (_es.showView) {
+                ESVideo.shareInstance.snapImageCallback = snapImageCallback;
                 _es.delegate = self;
                 _es.showView.backgroundColor = [UIColor whiteColor];
                 [self.centerView addSubview:_es.showView];
+                _es.showView.hidden = YES;
             }
         }else{
             NSLog(@"ESVideoPhone 鍒濆鍖栧け璐�");
@@ -680,9 +698,19 @@
     [alertController addAction:[UIAlertAction actionWithTitle:okStr style:UIAlertActionStyleCancel handler:nil]];
     [self presentViewController:alertController animated:YES completion:nil];
     
-//    UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:tipStr message:mes delegate:self cancelButtonTitle:okStr otherButtonTitles:nil, nil];
-//    [alertView1 show];
+    //    UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:tipStr message:mes delegate:self cancelButtonTitle:okStr otherButtonTitles:nil, nil];
+    //    [alertView1 show];
     
+}
+
+-(void)showUIAlertViewWithBack:(NSString *)mes
+{
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:tipStr message:mes preferredStyle:UIAlertControllerStyleAlert];
+    [alertController addAction:[UIAlertAction actionWithTitle:okStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        [self backAction];
+    }]];
+    
+    [self presentViewController:alertController animated:YES completion:nil];
 }
 
 
@@ -711,11 +739,11 @@
         [_es stopTalk];
         
         _es.delegate = nil;
-        
+        ESVideo.shareInstance.snapImageCallback = nil;
         
         
     }
-    [_es freeSubClass];
+    //    [_es freeSubClass];
 }
 -(void)dealloc{
     [[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -744,6 +772,7 @@
     NSString *phoneEventStr = eventArray.lastObject;
     
     if([phoneEventStr isEqual:@"EVT_Ringing"]){
+        _es.showView.hidden = NO;
         //鍙嶅懠鎴愬姛 鍏佽鎺ュ惉  鐪嬮渶姹傛槸鍚﹂渶瑕佹挱鏀鹃搩澹板拰闇囧姩
         [self setAnswerBtnEnable:YES];
         
@@ -753,8 +782,10 @@
     } else if([phoneEventStr isEqual:@"EVT_StopStream"]){
         //           [_mCallOrAccept setTitle:@"鍙嶅懠" forState:UIControlStateNormal];
     }else if([phoneEventStr isEqual:@"EVT_Connected"]){
+        
         //           [_mCallOrAccept setTitle:@"閫氳瘽涓�..." forState:UIControlStateNormal];
     }else if([phoneEventStr  isEqual:@"EVT_HangUp"]){
+        [self showUIAlertViewWithBack:@"宸叉寕鏂�"];
         //           [_mCallOrAccept setTitle:@"鍙嶅懠" forState:UIControlStateNormal];
     }else if([phoneEventStr  isEqual:@"EVT_P2POnlineStatusChanged"]){
         //EVT_P2PStarted(p2p鍒濆鍖朞K锛屽彲浠ヨ繛鎺�),EVT_P2POnlineStatusChangedonline=1

--
Gitblit v1.8.0