-
Notifications
You must be signed in to change notification settings - Fork 461
修复一系列测试提出的Bug; #323
base: master
Are you sure you want to change the base?
修复一系列测试提出的Bug; #323
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ @interface LCCKChatBar () <UITextViewDelegate, UINavigationControllerDelegate, M | |
@property (assign, nonatomic) CGFloat oldTextViewHeight; | ||
@property (nonatomic, assign, getter=shouldAllowTextViewContentOffset) BOOL allowTextViewContentOffset; | ||
@property (nonatomic, assign, getter=isClosed) BOOL close; | ||
@property (nonatomic, assign) BOOL outTime;//是否超时 | ||
|
||
#pragma mark - MessageInputView Customize UI | ||
///============================================================================= | ||
|
@@ -123,6 +124,8 @@ - (void)setupConstraints { | |
- (void)dealloc { | ||
self.delegate = nil; | ||
_faceView.delegate = nil; | ||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; | ||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"LCCKChatBarRecordVoiceOutTime" object:nil]; | ||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; | ||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; | ||
} | ||
|
@@ -345,7 +348,8 @@ - (void)endConvertWithMP3FileName:(NSString *)fileName { | |
} | ||
|
||
- (void)failRecord { | ||
[LCCKProgressHUD dismissWithProgressState:LCCKProgressError]; | ||
// 此回调在录音时长小于1时调用 应该提示Short而不是Error | ||
[LCCKProgressHUD dismissWithProgressState:LCCKProgressShort]; | ||
} | ||
|
||
- (void)beginConvert { | ||
|
@@ -474,6 +478,7 @@ - (UIView *)inputBarBackgroundView { | |
|
||
- (void)setup { | ||
self.close = NO; | ||
self.outTime = NO; | ||
self.oldTextViewHeight = kLCCKChatBarTextViewFrameMinHeight; | ||
self.allowTextViewContentOffset = YES; | ||
self.MP3 = [[Mp3Recorder alloc] initWithDelegate:self]; | ||
|
@@ -494,6 +499,10 @@ - (void)setup { | |
make.left.and.right.and.top.equalTo(self.inputBarBackgroundView); | ||
make.height.mas_equalTo(.5f); | ||
}]; | ||
|
||
//修复录音时点击Home键 在返回App后 仍然显示录音动效的问题 | ||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appBecomeBackgroundCancelRecordVoice) name:UIApplicationDidEnterBackgroundNotification object:nil]; | ||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appRecieveMsgFromRecordTimer) name:@"LCCKChatBarRecordVoiceOutTime" object:nil]; | ||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; | ||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; | ||
self.backgroundColor = self.messageInputViewBackgroundColor; | ||
|
@@ -504,9 +513,29 @@ - (void)setup { | |
* 开始录音 | ||
*/ | ||
- (void)startRecordVoice { | ||
[LCCKProgressHUD show]; | ||
self.voiceRecordButton.highlighted = YES; | ||
[self.MP3 startRecord]; | ||
// 判断权限 | ||
if ([self JudgeAVAudioSession]) { | ||
[LCCKProgressHUD show]; | ||
self.voiceRecordButton.highlighted = YES; | ||
[self.MP3 startRecord]; | ||
} else { | ||
[[NSNotificationCenter defaultCenter] postNotificationName:LCCKNotificationRecordNoPower object:nil]; | ||
} | ||
} | ||
|
||
- (BOOL)JudgeAVAudioSession { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个方法名应该以小写字母开头。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好的 |
||
__block BOOL bCanRecord = YES; | ||
AVAudioSession *audioSession = [AVAudioSession sharedInstance]; | ||
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ChatKit 支持 iOS 7 及以上, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我看看 这个修改本来只是自己项目里用 不小心提过来了 |
||
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) { | ||
if (granted) { | ||
bCanRecord = YES; | ||
} else { | ||
bCanRecord = NO; | ||
} | ||
}]; | ||
} | ||
return bCanRecord; | ||
} | ||
|
||
/** | ||
|
@@ -522,9 +551,12 @@ - (void)cancelRecordVoice { | |
* 录音结束 | ||
*/ | ||
- (void)confirmRecordVoice { | ||
[self.MP3 stopRecord]; | ||
if (self.outTime == NO) { | ||
[self.MP3 stopRecord]; | ||
} else { | ||
self.outTime = NO; | ||
} | ||
} | ||
|
||
/** | ||
* 更新录音显示状态,手指向上滑动后提示松开取消录音 | ||
*/ | ||
|
@@ -539,6 +571,26 @@ - (void)updateContinueRecordVoice { | |
[LCCKProgressHUD changeSubTitle:@"向上滑动取消录音"]; | ||
} | ||
|
||
/** | ||
* 进入后台 取消当前的录音 | ||
*/ | ||
- (void)appBecomeBackgroundCancelRecordVoice { | ||
[self cancelRecordVoice]; | ||
} | ||
|
||
/** | ||
* 倒计时结束 完成当前的录音 | ||
*/ | ||
- (void)appRecieveMsgFromRecordTimer | ||
{ | ||
if (self.voiceRecordButton.highlighted == YES) { | ||
self.voiceRecordButton.selected = NO; | ||
self.voiceRecordButton.highlighted = NO; | ||
[self.MP3 stopRecord]; | ||
self.outTime = YES; | ||
} | ||
} | ||
|
||
- (void)setShowType:(LCCKFunctionViewShowType)showType { | ||
if (_showType == showType) { | ||
return; | ||
|
@@ -664,6 +716,10 @@ - (void)sendTextMessage:(NSString *)text{ | |
if (!text || text.length == 0 || [text lcck_isSpace]) { | ||
return; | ||
} | ||
if (text.length > 1000) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 您好,请把这个数字作为一个常量,放在 LCCKConstants.h 中,例如:
然后在 alert 中也用这个常量来构造提示信息。 |
||
[[NSNotificationCenter defaultCenter] postNotificationName:LCCKNotificationTextOutLength object:nil]; | ||
return; | ||
} | ||
if (self.delegate && [self.delegate respondsToSelector:@selector(chatBar:sendMessage:)]) { | ||
[self.delegate chatBar:self sendMessage:text]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是用 timeout / timedOut / isTimedOut 之类的作为属性名更好?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的