Commit 82c48b2a by 刘鹏

feat: 云信权限判断修改

parent 48afe0f2
...@@ -14,7 +14,7 @@ buildscript { ...@@ -14,7 +14,7 @@ buildscript {
ydlrouter_version = '1.2.3' ydlrouter_version = '1.2.3'
constrait_support_version = '1.0.2' constrait_support_version = '1.0.2'
componentVersion = "0.3.0.42.1-SNAPSHOT" componentVersion = "0.3.0.42.2-SNAPSHOT"
} }
repositories { repositories {
mavenCentral() mavenCentral()
......
package com.yidianling.avchatkit.activity; package com.yidianling.avchatkit.activity;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemClock; import android.os.SystemClock;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -118,13 +120,7 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ ...@@ -118,13 +120,7 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
// 接听来电 // 接听来电
public static void incomingCall(Context context, AVChatData config, String displayName, int source) { public static void incomingCall(Context context, AVChatData config, String displayName, int source) {
needFinish = false; needFinish = false;
Intent intent = new Intent(); Intent intent = incomingCallIntent(context, config, displayName, source);
intent.setClass(context, AVChatActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(KEY_CALL_CONFIG, config);
intent.putExtra(KEY_DISPLAY_NAME, displayName);
intent.putExtra(KEY_IN_CALLING, true);
intent.putExtra(KEY_SOURCE, source);
context.startActivity(intent); context.startActivity(intent);
} }
@NonNull @NonNull
...@@ -143,6 +139,10 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ ...@@ -143,6 +139,10 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (getIntent().hasExtra(KEY_NEED_FINISH)) {
needFinish = getIntent().getBooleanExtra(KEY_NEED_FINISH, false);
}
// 若来电或去电未接通时,点击home。另外一方挂断通话。从最近任务列表恢复,则finish // 若来电或去电未接通时,点击home。另外一方挂断通话。从最近任务列表恢复,则finish
if (needFinish) { if (needFinish) {
finish(); finish();
...@@ -184,7 +184,6 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ ...@@ -184,7 +184,6 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
hasOnPause = true; hasOnPause = true;
} }
@Override @Override
...@@ -662,6 +661,7 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ ...@@ -662,6 +661,7 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
avChatData != null ? avChatData.getAccount() : receiverId); avChatData != null ? avChatData.getAccount() : receiverId);
} }
@SuppressLint("CheckResult")
@Override @Override
public void onAudioToVideo() { public void onAudioToVideo() {
new RxPermissions(this) new RxPermissions(this)
...@@ -729,7 +729,11 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ ...@@ -729,7 +729,11 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
@Override @Override
public void finish() { public void finish() {
isUserFinish = true; isUserFinish = true;
super.finish(); if (mIsInComingCall && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
super.finishAndRemoveTask();
} else {
super.finish();
}
} }
......
package com.yidianling.avchatkit.ui; package com.yidianling.avchatkit.ui;
import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
...@@ -10,13 +9,13 @@ import android.widget.Button; ...@@ -10,13 +9,13 @@ import android.widget.Button;
import android.widget.Chronometer; import android.widget.Chronometer;
import android.widget.TextView; import android.widget.TextView;
import com.blankj.utilcode.constant.PermissionConstants;
import com.blankj.utilcode.util.PermissionUtils;
import com.netease.nimlib.sdk.avchat.AVChatCallback; import com.netease.nimlib.sdk.avchat.AVChatCallback;
import com.netease.nimlib.sdk.avchat.AVChatManager; import com.netease.nimlib.sdk.avchat.AVChatManager;
import com.netease.nimlib.sdk.avchat.constant.AVChatControlCommand; import com.netease.nimlib.sdk.avchat.constant.AVChatControlCommand;
import com.netease.nimlib.sdk.avchat.constant.AVChatType; import com.netease.nimlib.sdk.avchat.constant.AVChatType;
import com.netease.nimlib.sdk.avchat.model.AVChatData; import com.netease.nimlib.sdk.avchat.model.AVChatData;
import com.tbruyelle.rxpermissions2.Permission;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.ydl.ydlcommon.utils.DeviceTool; import com.ydl.ydlcommon.utils.DeviceTool;
import com.yidianling.avchatkit.AVChatKit; import com.yidianling.avchatkit.AVChatKit;
import com.yidianling.avchatkit.activity.AVChatActivity; import com.yidianling.avchatkit.activity.AVChatActivity;
...@@ -34,7 +33,7 @@ import com.yidianling.avchatkit.module.AVSwitchListener; ...@@ -34,7 +33,7 @@ import com.yidianling.avchatkit.module.AVSwitchListener;
import com.yidianling.common.tools.ToastUtil; import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R; import com.yidianling.im.R;
import io.reactivex.functions.Consumer; import java.util.List;
/** /**
* 音频界面显示变化以及点击事件 * 音频界面显示变化以及点击事件
...@@ -383,22 +382,21 @@ public class AVChatAudioUI implements View.OnClickListener, ToggleListener { ...@@ -383,22 +382,21 @@ public class AVChatAudioUI implements View.OnClickListener, ToggleListener {
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
private void requestPermission() { private void requestPermission() {
new RxPermissions((Activity) this.context) PermissionUtils
.requestEach(Manifest.permission.RECORD_AUDIO,Manifest.permission.CAMERA) .permission(PermissionConstants.MICROPHONE, PermissionConstants.CAMERA)
.subscribe(new Consumer<Permission>() { .callback(new PermissionUtils.FullCallback() {
@Override @Override
public void accept(Permission permission) throws Exception { public void onGranted(List<String> permissionsGranted) {
if (permission.granted) { doReceiveCall();
doReceiveCall();
} else if (permission.shouldShowRequestPermissionRationale){
requestPermission();
}else {
ToastUtil.toastLong(context,"请开启相机和麦克风权限后重试");
DeviceTool.openPersisonSetting((Activity) AVChatAudioUI.this.context);
((Activity) AVChatAudioUI.this.context).finish();
}
} }
} );
@Override
public void onDenied(List<String> permissionsDeniedForever, List<String> permissionsDenied) {
ToastUtil.toastLong(context, "请开启相机和麦克风权限后重试");
DeviceTool.openPersisonSetting((Activity) AVChatAudioUI.this.context);
((Activity) AVChatAudioUI.this.context).finish();
}
}).request();
} }
// 接听来电 // 接听来电
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment