Skip to content

Commit

Permalink
Merge pull request #92 from jpush/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
KenChoi1992 authored Aug 11, 2017
2 parents 4c24006 + b674243 commit d1d7dee
Show file tree
Hide file tree
Showing 59 changed files with 1,030 additions and 345 deletions.
12 changes: 8 additions & 4 deletions Android/chatinput/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

- Gradle
```groovy
compile 'cn.jiguang.imui:chatinput:0.4.3'
compile 'cn.jiguang.imui:chatinput:0.4.5'
```

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

Expand Down Expand Up @@ -196,9 +196,13 @@ mChatInput.setOnCameraCallbackListener(new OnCameraCallbackListener() {
});
```

### 设置拍照后保存的文件
### 设置拍照后保存的文件(0.4.5 版本后弃用)
`setCameraCaptureFile(String path, String fileName)`

0.4.5 版本后拍照会返回默认路径。

```java
// 参数分别是路径及文件名,建议在上面的 onCameraClick 触发时调用
// 0.4.5 后弃用
mChatInput.setCameraCaptureFile(path, fileName);
```
11 changes: 7 additions & 4 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.4.3'
compile 'cn.jiguang.imui:chatinput:0.4.5'
```

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

Expand Down Expand Up @@ -206,11 +206,14 @@ mChatInput.setOnCameraCallbackListener(new OnCameraCallbackListener() {
});
```

#### Set file path and file name that after taken picture
#### Set file path and file name that after taken picture(Deprecated since 0.4.5)
setCameraCaptureFile(String path, String fileName)

Since 0.4.5, take picture will return default path.

```java
// The first parameter is file path that saved at, second one is file name
// Suggest calling this method when onCameraClick fires
// Deprecated since 0.4.5
mChatInput.setCameraCaptureFile(path, fileName);
```
57 changes: 57 additions & 0 deletions Android/chatinput/android-release-aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// ./gradlew clean build generateRelease
apply plugin: 'maven'

def groupId = project.PUBLISH_GROUP_ID
def artifactId = project.PUBLISH_ARTIFACT_ID
def version = project.PUBLISH_VERSION

def localReleaseDest = "${buildDir}/release/${version}"

task androidJavadocs(type: Javadoc) {
failOnError = false
source = android.sourceSets.main.java.srcDirs
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath += files(ext.androidJar)
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}

uploadArchives {
repositories.mavenDeployer {
pom.groupId = groupId
pom.artifactId = artifactId
pom.version = version
// Add other pom properties here if you want (developer details / licenses)
repository(url: "file://${localReleaseDest}")
}
}

task zipRelease(type: Zip) {
from localReleaseDest
destinationDir buildDir
archiveName "release-${version}.zip"
}

task generateRelease {
doLast {
println "Release ${version} can be found at ${localReleaseDest}/"
println "Release ${version} zipped can be found ${buildDir}/release-${version}.zip"
}
}

generateRelease.dependsOn(uploadArchives)
generateRelease.dependsOn(zipRelease)


artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
4 changes: 2 additions & 2 deletions 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.4.4'
PUBLISH_VERSION = '0.4.5'
}

android {
Expand Down Expand Up @@ -42,4 +42,4 @@ dependencies {
testCompile 'junit:junit:4.12'
}

apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
apply from: 'android-release-aar.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.support.v4.widget.Space;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
Expand Down Expand Up @@ -49,13 +48,12 @@
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;

import cn.jiguang.imui.chatinput.camera.CameraNew;
import cn.jiguang.imui.chatinput.camera.CameraOld;
import cn.jiguang.imui.chatinput.camera.CameraSupport;
import cn.jiguang.imui.chatinput.listener.CameraEventListener;
import cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener;
import cn.jiguang.imui.chatinput.listener.OnClickEditTextListener;
import cn.jiguang.imui.chatinput.listener.OnFileSelectedListener;
Expand All @@ -69,7 +67,7 @@

public class ChatInputView extends LinearLayout
implements View.OnClickListener, TextWatcher, RecordControllerView.OnRecordActionListener,
OnFileSelectedListener {
OnFileSelectedListener, CameraEventListener {

public static final byte KEYBOARD_STATE_SHOW = -3;
public static final byte KEYBOARD_STATE_HIDE = -2;
Expand Down Expand Up @@ -150,7 +148,6 @@ public class ChatInputView extends LinearLayout
private FileInputStream mFIS;
private FileDescriptor mFD;
private boolean mIsEarPhoneOn;

private File mPhoto;
private CameraSupport mCameraSupport;
private int mCameraId = -1;
Expand Down Expand Up @@ -398,16 +395,6 @@ public void onClick(View view) {
mListener.switchToCameraMode();
}
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
if (mPhoto == null) {
String path = getContext().getFilesDir().getAbsolutePath() + "/photo";
File destDir = new File(path);
if (!destDir.exists()) {
destDir.mkdirs();
}
mPhoto = new File(destDir,
DateFormat.format("yyyy_MMdd_hhmmss", Calendar.getInstance(Locale.CHINA))
+ ".png");
}
if (mCameraSupport == null) {
initCamera();
}
Expand Down Expand Up @@ -532,9 +519,6 @@ public void run() {
// take picture and send it
} else {
mCameraSupport.takePicture();
if (mIsFullScreen) {
recoverScreen();
}
}
} else if (view.getId() == R.id.aurora_ib_camera_close) {
try {
Expand Down Expand Up @@ -685,7 +669,7 @@ private void initCamera() {
mCameraSupport = new CameraOld(getContext(), mTextureView);
}
mCameraSupport.setCameraCallbackListener(mCameraListener);
mCameraSupport.setOutputFile(mPhoto);
mCameraSupport.setCameraEventListener(this);
for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(i, info);
Expand All @@ -708,7 +692,7 @@ public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width,
int height) {
Log.e("ChatInputView", "Texture size changed, Opening camera");
if (mTextureView.getVisibility() == VISIBLE) {
if (mTextureView.getVisibility() == VISIBLE && mCameraSupport != null) {
mCameraSupport.open(mCameraId, width, height, mIsBackCamera);
}
}
Expand Down Expand Up @@ -752,26 +736,31 @@ private void fullScreen() {
* Recover screen
*/
private void recoverScreen() {
Activity activity = (Activity) getContext();
WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
activity.getWindow().setAttributes(attrs);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mIsFullScreen = false;
mCloseBtn.setVisibility(GONE);
mFullScreenBtn.setBackgroundResource(R.drawable.aurora_preview_full_screen);
mFullScreenBtn.setVisibility(VISIBLE);
mChatInputContainer.setVisibility(VISIBLE);
mMenuItemContainer.setVisibility(VISIBLE);
setMenuContainerHeight(sMenuHeight);
ViewGroup.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, sMenuHeight);
mTextureView.setLayoutParams(params);
mRecordVideoBtn.setBackgroundResource(R.drawable.aurora_preview_record_video);
mRecordVideoBtn.setVisibility(VISIBLE);
mSwitchCameraBtn.setBackgroundResource(R.drawable.aurora_preview_switch_camera);
mSwitchCameraBtn.setVisibility(VISIBLE);
mCaptureBtn.setBackgroundResource(R.drawable.aurora_menuitem_send_pres);
final Activity activity = (Activity) getContext();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
activity.getWindow().setAttributes(attrs);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mIsFullScreen = false;
mCloseBtn.setVisibility(GONE);
mFullScreenBtn.setBackgroundResource(R.drawable.aurora_preview_full_screen);
mFullScreenBtn.setVisibility(VISIBLE);
mChatInputContainer.setVisibility(VISIBLE);
mMenuItemContainer.setVisibility(VISIBLE);
setMenuContainerHeight(sMenuHeight);
ViewGroup.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, sMenuHeight);
mTextureView.setLayoutParams(params);
mRecordVideoBtn.setBackgroundResource(R.drawable.aurora_preview_record_video);
mRecordVideoBtn.setVisibility(VISIBLE);
mSwitchCameraBtn.setBackgroundResource(R.drawable.aurora_preview_switch_camera);
mSwitchCameraBtn.setVisibility(VISIBLE);
mCaptureBtn.setBackgroundResource(R.drawable.aurora_menuitem_send_pres);
}
});
}

public void dismissMenuLayout() {
Expand Down Expand Up @@ -966,12 +955,13 @@ public void onAnimationRepeat(Animator animator) {
}

/**
* Set aurora_menuitem_camera capture file path and file name. If user didn't invoke this method, will save in
* Set camera capture file path and file name. If user didn't invoke this method, will save in
* default path.
*
* @param path Photo to be saved in.
* @param fileName File name.
*/
@Deprecated
public void setCameraCaptureFile(String path, String fileName) {
File destDir = new File(path);
if (!destDir.exists()) {
Expand Down Expand Up @@ -1107,4 +1097,11 @@ public void onWindowVisibilityChanged(int visibility) {
}
}
}

@Override
public void onFinishTakePicture() {
if (mIsFullScreen) {
recoverScreen();
}
}
}
Loading

0 comments on commit d1d7dee

Please sign in to comment.