AudioMeetingViewController.mm 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // AudioMeetingViewController.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 17/3/28.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "AudioMeetingViewController.h"
  9. #import "CallViewController.h"
  10. @interface AudioMeetingViewController ()<UITextFieldDelegate>
  11. {
  12. NgnBaseService<INgnSipService>* mSipService;
  13. UILabel * _noticeLabel;
  14. UITextField * _phoneTextF;
  15. UIButton * _starMeetBtn;
  16. UILabel * _loginStateLabel;
  17. }
  18. @end
  19. @implementation AudioMeetingViewController
  20. - (id)init
  21. {
  22. self = [super init];
  23. if (self) {
  24. self.title = Localized(@"JX_Meeting");
  25. self.isGotoBack = YES;
  26. self.heightHeader = JX_SCREEN_TOP;
  27. self.heightFooter = 0;
  28. mSipService = [[NgnEngine sharedInstance] getSipService];
  29. if (!_type) {
  30. _type = AudioMeetingTypeNumberByUserSelf;
  31. }
  32. }
  33. return self;
  34. }
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. // Do any additional setup after loading the view.
  38. //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  39. [self createHeadAndFoot];
  40. self.tableBody.backgroundColor = HEXCOLOR(0xf0eff4);
  41. // self.tableBody.contentSize = CGSizeMake(self_width, self_height);
  42. [self customUI];
  43. if (![self updateLoginState]) {
  44. [g_meeting stopMeeting];
  45. [g_meeting startMeeting];
  46. }
  47. }
  48. -(void)viewDidAppear:(BOOL)animated{
  49. [super viewDidAppear:animated];
  50. [_wait start:Localized(@"JXAudioMeetingVC_LoginSIP") delay:1.5];
  51. [self performSelector:@selector(updateLoginState) withObject:nil afterDelay:1.5];
  52. }
  53. -(BOOL)updateLoginState{
  54. if([[[NgnEngine sharedInstance] getSipService] isRegistered]){
  55. NSLog(@"ngn isRegistered success");
  56. _loginStateLabel.text = Localized(@"JXAudioMeetingVC_LoginFinish");
  57. _loginStateLabel.textColor = [UIColor greenColor];
  58. _starMeetBtn.enabled = YES;
  59. _starMeetBtn.backgroundColor = THEMECOLOR;
  60. return YES;
  61. }
  62. else {
  63. NSLog(@"ngn isRegistered faild");
  64. _loginStateLabel.text = Localized(@"JXAudioMeeting_NotLogin");
  65. _loginStateLabel.textColor = [UIColor grayColor];
  66. _starMeetBtn.enabled = NO;
  67. _starMeetBtn.backgroundColor = [UIColor grayColor];
  68. return NO;
  69. }
  70. }
  71. - (void)didReceiveMemoryWarning {
  72. [super didReceiveMemoryWarning];
  73. // Dispose of any resources that can be recreated.
  74. }
  75. -(void)customUI{
  76. _loginStateLabel = [UIFactory createLabelWith:CGRectMake(JX_SCREEN_WIDTH-60-10, 10, 60, 20) text:Localized(@"JXAudioMeeting_NotLogin") font:g_factory.font13 textColor:[UIColor blackColor] backgroundColor:nil];
  77. _loginStateLabel.textAlignment = NSTextAlignmentCenter;
  78. [self.tableBody addSubview:_loginStateLabel];
  79. _noticeLabel = [UIFactory createLabelWith:CGRectMake(25, CGRectGetMaxY(_loginStateLabel.frame)+15, JX_SCREEN_WIDTH-25*2, 60) text:@"" font:g_factory.font16 textColor:[UIColor blackColor] backgroundColor:nil];
  80. _noticeLabel.numberOfLines = 0;
  81. _noticeLabel.textAlignment = NSTextAlignmentCenter;
  82. [self.tableBody addSubview:_noticeLabel];
  83. if (_type == AudioMeetingTypeNumberByUserSelf) {
  84. _noticeLabel.text = Localized(@"JXAudioMeeting_InputPassWordToMeeting");
  85. _phoneTextF = [UIFactory createTextFieldWithRect:CGRectMake((JX_SCREEN_WIDTH-100)/2, CGRectGetMaxY(_noticeLabel.frame)+15, 100, 30) keyboardType:UIKeyboardTypePhonePad secure:NO placeholder:@"****" font:g_factory.font14 color:[UIColor blackColor] delegate:self];
  86. }else if (_type == AudioMeetingTypeGroupCall) {
  87. _noticeLabel.text = Localized(@"JXAudioMeeting_StartGroupCallNotice");
  88. _phoneTextF = [UIFactory createTextFieldWithRect:CGRectMake((JX_SCREEN_WIDTH-150)/2, CGRectGetMaxY(_noticeLabel.frame)+15, 150, 30) keyboardType:UIKeyboardTypePhonePad secure:NO placeholder:nil font:g_factory.font14 color:[UIColor blackColor] delegate:self];
  89. _phoneTextF.text = self.call;
  90. }
  91. [self.tableBody addSubview:_phoneTextF];
  92. _starMeetBtn = [UIFactory createButtonWithRect:CGRectMake(25, CGRectGetMaxY(_phoneTextF.frame) +50, JX_SCREEN_WIDTH-25*2, 40) title:Localized(@"JXAudioMeetingVC_StartMeeting") titleFont:g_factory.font16 titleColor:[UIColor whiteColor] normal:nil selected:nil selector:@selector(startMeeting) target:self];
  93. _starMeetBtn.backgroundColor = THEMECOLOR;
  94. _starMeetBtn.layer.masksToBounds = YES;
  95. _starMeetBtn.layer.cornerRadius = 7;
  96. [self.tableBody addSubview:_starMeetBtn];
  97. }
  98. -(void)startMeeting{
  99. if (_phoneTextF.text.length <= 0){
  100. return;
  101. }
  102. [_phoneTextF resignFirstResponder];
  103. [CallViewController makeAudioCallWithRemoteParty:_phoneTextF.text toUserName:nil andSipStack: [mSipService getSipStack]];
  104. }
  105. /*
  106. #pragma mark - Navigation
  107. // In a storyboard-based application, you will often want to do a little preparation before navigation
  108. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  109. // Get the new view controller using [segue destinationViewController].
  110. // Pass the selected object to the new view controller.
  111. }
  112. */
  113. @end