Commit 82c48b2a by 刘鹏

feat: 云信权限判断修改

parent 48afe0f2
......@@ -14,7 +14,7 @@ buildscript {
ydlrouter_version = '1.2.3'
constrait_support_version = '1.0.2'
componentVersion = "0.3.0.42.1-SNAPSHOT"
componentVersion = "0.3.0.42.2-SNAPSHOT"
}
repositories {
mavenCentral()
......
package com.yidianling.avchatkit.activity;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.LayoutInflater;
......@@ -118,13 +120,7 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
// 接听来电
public static void incomingCall(Context context, AVChatData config, String displayName, int source) {
needFinish = false;
Intent intent = new Intent();
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);
Intent intent = incomingCallIntent(context, config, displayName, source);
context.startActivity(intent);
}
@NonNull
......@@ -143,6 +139,10 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().hasExtra(KEY_NEED_FINISH)) {
needFinish = getIntent().getBooleanExtra(KEY_NEED_FINISH, false);
}
// 若来电或去电未接通时,点击home。另外一方挂断通话。从最近任务列表恢复,则finish
if (needFinish) {
finish();
......@@ -184,7 +184,6 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
protected void onPause() {
super.onPause();
hasOnPause = true;
}
@Override
......@@ -662,6 +661,7 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
avChatData != null ? avChatData.getAccount() : receiverId);
}
@SuppressLint("CheckResult")
@Override
public void onAudioToVideo() {
new RxPermissions(this)
......@@ -729,8 +729,12 @@ public class AVChatActivity extends AVChatBaseUI implements AVChatVideoUI.TouchZ
@Override
public void finish() {
isUserFinish = true;
if (mIsInComingCall && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
super.finishAndRemoveTask();
} else {
super.finish();
}
}
@Override
......
package com.yidianling.avchatkit.ui;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
......@@ -10,13 +9,13 @@ import android.widget.Button;
import android.widget.Chronometer;
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.AVChatManager;
import com.netease.nimlib.sdk.avchat.constant.AVChatControlCommand;
import com.netease.nimlib.sdk.avchat.constant.AVChatType;
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.yidianling.avchatkit.AVChatKit;
import com.yidianling.avchatkit.activity.AVChatActivity;
......@@ -34,7 +33,7 @@ import com.yidianling.avchatkit.module.AVSwitchListener;
import com.yidianling.common.tools.ToastUtil;
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 {
@SuppressLint("CheckResult")
private void requestPermission() {
new RxPermissions((Activity) this.context)
.requestEach(Manifest.permission.RECORD_AUDIO,Manifest.permission.CAMERA)
.subscribe(new Consumer<Permission>() {
PermissionUtils
.permission(PermissionConstants.MICROPHONE, PermissionConstants.CAMERA)
.callback(new PermissionUtils.FullCallback() {
@Override
public void accept(Permission permission) throws Exception {
if (permission.granted) {
public void onGranted(List<String> permissionsGranted) {
doReceiveCall();
} else if (permission.shouldShowRequestPermissionRationale){
requestPermission();
}else {
ToastUtil.toastLong(context,"请开启相机和麦克风权限后重试");
}
@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