Skip to content

Commit

Permalink
Merge pull request #312 from jpush/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
KenChoi1992 committed Mar 22, 2018
2 parents 1e65cc0 + 785a473 commit 8ff14a6
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 90 deletions.
27 changes: 23 additions & 4 deletions Android/chatinput/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
这是一个聊天界面输入框组件,可以方便地结合 `MessageList` 使用,包含录音,选择图片,拍照等功能,提供了一些丰富的接口和回调供用户使用,
还可以选择自定义样式。

> 该组件依赖了 Glide 3.7.0
> 该组件依赖了 Glide 3.8.0
## 集成
提供了以下几种方式添加依赖,只需要选择其中一种即可。

- Gradle
```groovy
compile 'cn.jiguang.imui:chatinput:0.7.2'
compile 'cn.jiguang.imui:chatinput:0.7.3'
```

- Maven
```
<dependency>
<groupId>cn.jiguang.imui</groupId>
<artifactId>chatinput</artifactId>
<version>0.7.2</version>
<version>0.7.3</version>
<type>pom</type>
</dependency>
```
Expand All @@ -42,7 +42,7 @@ compile 'cn.jiguang.imui:chatinput:0.7.2'
```groovy
dependencies {
compile 'com.github.jpush:imui:0.7.5'
compile 'com.github.jpush:imui:0.7.6'
}
```

Expand Down Expand Up @@ -163,6 +163,24 @@ mRecordVoiceBtn.setRecordVoiceListener(new RecordVoiceListener() {
public void onCancelRecord() {

}

/**
* 录音试听界面,点击取消按钮触发
* 0.7.3 后添加此事件
*/
@Override
public void onPreviewCancel() {

}

/**
* 录音试听界面,点击发送按钮触发
* 0.7.3 后增加此事件
*/
@Override
public void onPreviewSend() {

}
});
```

Expand Down Expand Up @@ -198,6 +216,7 @@ mChatInput.setOnCameraCallbackListener(new OnCameraCallbackListener() {
public void onCancelVideoRecord() {

}

});
```

Expand Down
24 changes: 21 additions & 3 deletions Android/chatinput/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Provides several ways to add dependency, you can choose one of them:

- Via Gradle
```groovy
compile 'cn.jiguang.imui:chatinput:0.7.2'
compile 'cn.jiguang.imui:chatinput:0.7.3'
```

- Via Maven
Expand All @@ -20,7 +20,7 @@ compile 'cn.jiguang.imui:chatinput:0.7.2'
<dependency>
<groupId>cn.jiguang.imui</groupId>
<artifactId>chatinput</artifactId>
<version>0.7.2</version>
<version>0.7.3</version>
<type>pom</type>
</dependency>
```
Expand All @@ -41,7 +41,7 @@ allprojects {
```groovy
dependencies {
compile 'com.github.jpush:imui:0.7.5'
compile 'com.github.jpush:imui:0.7.6'
}
```

Expand Down Expand Up @@ -171,6 +171,24 @@ mRecordVoiceBtn.setRecordVoiceListener(new RecordVoiceListener() {
@Override
public void onCancelRecord() {

}

/**
* In preview record voice layout, fires when click cancel button
* Add since 0.7.3
*/
@Override
public void onPreviewCancel() {
}


/**
* In preview record voice layout, fires when click send button
* Add since chatinput 0.7.3
*/
@Override
public void onPreviewSend() {

}
});
```
Expand Down
2 changes: 1 addition & 1 deletion Android/chatinput/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'cn.jiguang.imui'
PUBLISH_ARTIFACT_ID = 'chatinput'
PUBLISH_VERSION = '0.7.2'
PUBLISH_VERSION = '0.7.3'
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import cn.jiguang.imui.chatinput.listener.OnClickEditTextListener;
import cn.jiguang.imui.chatinput.listener.OnFileSelectedListener;
import cn.jiguang.imui.chatinput.listener.OnMenuClickListener;
import cn.jiguang.imui.chatinput.listener.RecordVoiceListener;
import cn.jiguang.imui.chatinput.model.FileItem;
import cn.jiguang.imui.chatinput.model.VideoItem;
import cn.jiguang.imui.chatinput.photo.SelectPhotoView;
Expand Down Expand Up @@ -126,6 +127,7 @@ public class ChatInputView extends LinearLayout
private OnCameraCallbackListener mCameraListener;
private OnClickEditTextListener mEditTextListener;
private CameraControllerListener mCameraControllerListener;
private RecordVoiceListener mRecordVoiceListener;

private EmojiView mEmojiRl;

Expand Down Expand Up @@ -373,6 +375,11 @@ public void setMenuClickListener(OnMenuClickListener listener) {
mListener = listener;
}

public void setRecordVoiceListener(RecordVoiceListener listener) {
this.mRecordVoiceBtn.setRecordVoiceListener(listener);
this.mRecordVoiceListener = listener;
}

public void setOnCameraCallbackListener(OnCameraCallbackListener listener) {
mCameraListener = listener;
}
Expand Down Expand Up @@ -535,13 +542,19 @@ public void onClick(View view) {
mRecordContentLl.setVisibility(VISIBLE);
mRecordVoiceBtn.cancelRecord();
mChronometer.setText("00:00");
if (mRecordVoiceListener != null) {
mRecordVoiceListener.onPreviewCancel();
}

} else if (view.getId() == R.id.aurora_btn_recordvoice_send) {
// preview play audio widget send audio
mPreviewPlayLl.setVisibility(GONE);
dismissMenuLayout();
mRecordVoiceBtn.finishRecord();
mChronometer.setText("00:00");
if (mRecordVoiceListener != null) {
mRecordVoiceListener.onPreviewSend();
}

} else if (view.getId() == R.id.aurora_ib_camera_full_screen) {
// full screen/recover screen button in texture view
Expand Down Expand Up @@ -630,7 +643,9 @@ public void run() {
mCameraControllerListener.onCloseCameraClick();
mMediaPlayer.stop();
mMediaPlayer.release();
mCameraSupport.cancelRecordingVideo();
if (mCameraSupport != null) {
mCameraSupport.cancelRecordingVideo();
}
} catch (IllegalStateException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -1317,6 +1332,25 @@ public int getDistanceFromInputToBottom() {
return mHeight - mRect.bottom;
}

private final Runnable measureAndLayout = new Runnable() {
@Override
public void run() {
measure(
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
layout(getLeft(), getTop(), getRight(), getBottom());
}
};

@Override
public void requestLayout() {
super.requestLayout();

// React Native Override requestLayout, since we refresh our layout in native, RN catch the
//requestLayout event, so that the view won't refresh at once, we simulate layout here.
post(measureAndLayout);
}

public int getSoftKeyboardHeight() {
return this.mSoftKeyboardHeight;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,16 @@ public interface RecordVoiceListener {
* Fires when canceled recording, will delete the audio file.
*/
void onCancelRecord();

/**
* In preview record voice layout, click cancel button will fire this method.
* Add since 0.7.3
*/
void onPreviewCancel();

/**
* In preview record voice layout, click send voice button will fire this method.
* Add since 0.7.3
*/
void onPreviewSend();
}
2 changes: 1 addition & 1 deletion Android/messagelist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'cn.jiguang.imui'
PUBLISH_ARTIFACT_ID = 'messagelist'
PUBLISH_VERSION = '0.6.7'
PUBLISH_VERSION = '0.6.8'
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,20 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
}
return false;
}

@Override
public void requestLayout() {
super.requestLayout();
post(measureAndLayout);
}

private final Runnable measureAndLayout = new Runnable() {
@Override
public void run() {
measure(
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
layout(getLeft(), getTop(), getRight(), getBottom());
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,24 @@ public void onFinishRecord(File voiceFile, int duration) {
public void onCancelRecord() {

}

/**
* In preview record voice layout, fires when click cancel button
* Add since chatinput v0.7.3
*/
@Override
public void onPreviewCancel() {

}

/**
* In preview record voice layout, fires when click send button
* Add since chatinput v0.7.3
*/
@Override
public void onPreviewSend() {

}
});

mChatView.setOnCameraCallbackListener(new OnCameraCallbackListener() {
Expand Down Expand Up @@ -366,7 +384,6 @@ public void onReceive(Context context, Intent intent) {
}



@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void setCameraCaptureFile(String path, String fileName) {
}

public void setRecordVoiceListener(RecordVoiceListener listener) {
mRecordVoiceBtn.setRecordVoiceListener(listener);
mChatInput.setRecordVoiceListener(listener);
}

public void setOnCameraCallbackListener(OnCameraCallbackListener listener) {
Expand Down
4 changes: 2 additions & 2 deletions ReactNative/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'cn.jiguang.imui:messagelist:0.6.7'
compile 'cn.jiguang.imui:chatinput:0.7.2'
compile 'cn.jiguang.imui:messagelist:0.6.8'
compile 'cn.jiguang.imui:chatinput:0.7.3'
compile 'pub.devrel:easypermissions:0.4.0'
compile 'org.greenrobot:eventbus:3.0.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
Expand Down
Loading

0 comments on commit 8ff14a6

Please sign in to comment.