1010#import " UIView+Extend.h"
1111#import " NIMInputEmoticonManager.h"
1212#import " NIMInputAtCache.h"
13- #import " DWAudioRecorderManager.h"
13+ // #import "DWAudioRecorderManager.h"
1414#import < AVFoundation/AVFoundation.h>
1515
1616#define toolBackColor [UIColor colorWithRed: 247 /255.0 green: 247 /255.0 blue: 247 /255.0 alpha: 1.0 ];
1717
18- @interface DWInputBarControl ()<HPGrowingTextViewDelegate,DWRecordDelegate, NIMInputEmoticonProtocol>{
18+ @interface DWInputBarControl ()<HPGrowingTextViewDelegate,NIMInputEmoticonProtocol>{
1919 UIView *line;
2020 CGFloat tmpGrowViewH;
21- BOOL isHasVoiceAuth;
2221}
2322@property (nonatomic , strong ) NIMInputAtCache *atCache;
24- @property (copy , nonatomic ) NSString *strRecordPath;
23+ // @property (copy, nonatomic) NSString *strRecordPath;
2524@end
2625
2726@implementation DWInputBarControl
@@ -42,7 +41,7 @@ - (void)addNotification{
4241 // 监听选择@人的回调
4342 [[NSNotificationCenter defaultCenter ]addObserver:self selector: @selector (clickGetAtPerson: ) name: @" GetAtPersonNotification" object: nil ];
4443 [[NSNotificationCenter defaultCenter ]addObserver:self selector: @selector (growingTextViewDeleteBackward ) name: @" GrowTextViewDeleteBackWard" object: nil ];
45- [[NSNotificationCenter defaultCenter ]addObserver:self selector: @selector (clickSendRecordMessage ) name: @" FinishAudioRecordNotification" object: nil ];// 录音结束,发送录音message
44+ [[NSNotificationCenter defaultCenter ]addObserver:self selector: @selector (clickSendRecordMessage: ) name: @" FinishAudioRecordNotification" object: nil ];// 录音结束,发送录音message
4645}
4746
4847#pragma mark -- 监听键盘
@@ -58,8 +57,6 @@ - (void)clickKeyBoardChange:(NSNotification *)noti{
5857 self.onShowKeyboard (@{@" inputHeight" :@(tmpH),@" showType" :@(0 )});
5958 }
6059// [[NSNotificationCenter defaultCenter]postNotificationName:@"ChangeMessageListHeightNotification" object:@{@"listViewHeight":@(screenH - 60 - tmpH)}];
61-
62-
6360}
6461
6562- (void )hidenFeatureView {
@@ -143,15 +140,16 @@ - (void)setDefaultToolHeight:(CGFloat)defaultToolHeight{
143140 [self creatUI ];
144141}
145142// 发送录音message
146- - (void )clickSendRecordMessage {
143+ - (void )clickSendRecordMessage : (NSNotification *)noti {
144+ NSString *strRecordPath = noti.object ;
147145 dispatch_async (dispatch_get_main_queue (), ^{
148146 [_recordBtn setButtonStateWithNormal ];
149147 [[NSNotificationCenter defaultCenter ]postNotificationName:@" RecordChangeNotification" object: @" Complete" ];
150148 if (self.onSendRecordMessage ) {
151- self.onSendRecordMessage (@{@" Path" :self. strRecordPath });
149+ self.onSendRecordMessage (@{@" Path" :strRecordPath});
152150 }
153151 });
154- NSLog (@" strRecordPath:%@ " ,self. strRecordPath );
152+ NSLog (@" strRecordPath:%@ " ,strRecordPath);
155153}
156154
157155
@@ -188,7 +186,6 @@ - (void)addSubContentView{
188186 _recordBtn = [[DWRecordButton alloc ]init];
189187 _recordBtn.textArr = @[@" 按住 说话" ,@" 松开 结束" ,@" 松开 取消" ];
190188 _recordBtn.hidden = YES ;
191- _recordBtn.delegate = self;
192189 [_toolView addSubview: _recordBtn];
193190
194191 _showExpressionBtn = [[UIButton alloc ]init];
@@ -204,6 +201,8 @@ - (void)addSubContentView{
204201 _expressionView.delegate = self;
205202 [self addSubview: _expressionView];
206203 _expressionView.hidden = YES ;
204+ NIMInputEmoticonTabView *tab = _expressionView.tabView ;
205+
207206
208207 self.functionView = [[UIView alloc ]initWithFrame:CGRectMake (0 , 0 , screenW, menuViewH)];
209208 [self addSubview: _functionView];
@@ -263,88 +262,6 @@ - (void)clickControlBtn:(UIButton *)btn{
263262 }
264263}
265264
266- // 获取保存录音路径
267- - (NSString *)getSaveRecordPath {
268- NSString *dirPath = NSTemporaryDirectory ();
269- NSTimeInterval interval = [[NSDate date ] timeIntervalSince1970 ];
270- NSString *recordName = [NSString stringWithFormat: @" %.0f .aac" ,interval];
271- NSString *soundFilePath = [dirPath stringByAppendingPathComponent: recordName];
272- return soundFilePath;
273- }
274-
275- - (BOOL )getVoiceAVAuthorizationStatus {
276- [AVCaptureDevice requestAccessForMediaType:
277- AVMediaTypeAudio completionHandler: ^(BOOL granted)
278- {// 麦克风权限
279- if (granted) {
280- isHasVoiceAuth = YES ;
281- }else {
282- isHasVoiceAuth = NO ;
283- UIAlertView * alart = [[UIAlertView alloc ]initWithTitle:@" 温馨提示" message: @" 请您设置允许APP访问您的麦克风\n 设置>隐私>麦克风" delegate: self cancelButtonTitle: @" 确定" otherButtonTitles: nil , nil ];
284- [alart show ];
285- }
286- }];
287- return isHasVoiceAuth;
288- }
289-
290-
291- #pragma mark DWRecordButton录音按钮代理方法
292- - (void )recordTouchDownAction : (DWRecordButton *)btn {
293- NSLog (@" 开始录音" );
294- if ([self getVoiceAVAuthorizationStatus ]) {
295- if (!btn.selected ) {
296- btn.selected = YES ;
297- [btn setButtonStateWithRecording ];
298- [[NSNotificationCenter defaultCenter ]postNotificationName:@" RecordChangeNotification" object: @" Start" ];
299- _strRecordPath = [self getSaveRecordPath ];
300- [[DWAudioRecorderManager shareManager ] audioRecorderStartWithFilePath: _strRecordPath ];
301- }
302- }
303- }
304- - (void )recordTouchUpOutsideAction : (DWRecordButton *)btn {
305- if (isHasVoiceAuth) {
306- NSLog (@" 取消录音" );
307- [btn setButtonStateWithNormal ];
308- [[DWAudioRecorderManager shareManager ] audioRecorderCancel ];
309- [[NSNotificationCenter defaultCenter ]postNotificationName:@" RecordChangeNotification" object: @" Canceled" ];
310- }
311- }
312- - (void )recordTouchUpInsideAction : (DWRecordButton *)btn {
313- if (isHasVoiceAuth) {
314- NSLog (@" 完成录音" );
315- [btn setButtonStateWithNormal ];
316- [[DWAudioRecorderManager shareManager ] audioRecorderStop ];
317- }
318- }
319-
320- - (void )recordTouchDragInsideAction : (DWRecordButton *)btn {
321- // 持续调用
322-
323- }
324- - (void )recordTouchDragOutsideAction : (DWRecordButton *)btn {
325- // 持续调用
326-
327- }
328- // 中间状态 从 TouchDragOutside ---> TouchDragInside
329- - (void )recordTouchDragEnterAction : (DWRecordButton *)btn {
330- if (isHasVoiceAuth) {
331- if (btn.selected ) {
332- NSLog (@" 继续录音" );
333- [btn setButtonStateWithRecording ];
334- [[NSNotificationCenter defaultCenter ]postNotificationName:@" RecordChangeNotification" object: @" Continue" ];
335- }
336- }
337- }
338- // 中间状态 从 TouchDragInside ---> TouchDragOutside
339- - (void )recordTouchDragExitAction : (DWRecordButton *)btn {
340- if (isHasVoiceAuth) {
341- if (btn.selected ) {
342- NSLog (@" 将要取消录音" );
343- [btn setButtonStateWithCancel ];
344- [[NSNotificationCenter defaultCenter ]postNotificationName:@" RecordChangeNotification" object: @" Move" ];
345- }
346- }
347- }
348265
349266#pragma mark - HPGrowingTextViewDelegate
350267- (void )growingTextView : (HPGrowingTextView *)growingTextView willChangeHeight : (float )height {
@@ -408,7 +325,6 @@ - (void)selectedEmoticon:(NSString*)emoticonID catalog:(NSString*)emotCatalogID
408325 self.inputGrowView .text = [NSString stringWithFormat: @" %@%@ " ,_inputGrowView.text,description];
409326 }else {
410327 // 发送贴图消息
411-
412328 }
413329 }
414330}
@@ -417,6 +333,7 @@ - (void)didPressSend:(id)sender{
417333 NSArray *uuidArr = [self .atCache allAtUid: self .inputGrowView.text];
418334 self.onSendTextMessage (@{@" text" :self.inputGrowView .text ,@" IDArr" :uuidArr});
419335 self.inputGrowView .text = @" " ;
336+ [self .expressionView setupSendBtnCanSend: NO ];
420337}
421338
422339// 删除Text
@@ -485,6 +402,9 @@ - (void)deleteText:(NSRange)range
485402 NSRange newSelectRange = NSMakeRange (range.location , 0 );
486403 [self .inputGrowView setText: newText];
487404 self.inputGrowView .selectedRange = newSelectRange;
405+ if ((![self .inputGrowView.text length ]) && !self.expressionView .hidden ) {
406+ [self .expressionView setupSendBtnCanSend: NO ];
407+ }
488408 }
489409}
490410// 删除@的人
0 commit comments