wxr
2024-11-14 589eb3ae9f309dd7adaac7b5ee48f4a9259855f8
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneReverseCallActivity.java
@@ -4,8 +4,10 @@
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.media.AudioAttributes;
import android.media.MediaPlayer;
import android.os.Build;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.SystemClock;
import android.os.Vibrator;
import android.support.v7.app.AlertDialog;
@@ -50,6 +52,10 @@
    private ImageView iv_lp_hangUp;
    private TextView tv_lp_hangUp;
    private RelativeLayout rl_lp_hangUpAll;
    private ImageView iv_lp_hangUpAll;
    private TextView tv_lp_hangUpAll;
    private ImageView iv_lp_answer;
    private TextView tv_lp_answer;
    private RelativeLayout rl_lp_answerView;
@@ -77,6 +83,8 @@
    private String deviceSipAccount;//设备SIP账号
    private boolean enableVideo = false;
    private CountDownTimer mMissedCallsTimer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -91,7 +99,10 @@
        initCountDownTimer();
        initLinphone();
//        initVibrator();
        initMissedCallsTimer();
        mMissedCallsTimer.start();
    }
    /**
     * onDestroy
@@ -114,6 +125,10 @@
            mCountDownTimer.cancel();
            mCountDownTimer = null;
        }
        if (mMissedCallsTimer != null) {
            mMissedCallsTimer.cancel();
            mMissedCallsTimer = null;
        }
        onDestroyLinphone();
        HDLLog.i(TAG, "onDestroy");
    }
@@ -127,6 +142,9 @@
        iv_lp_unlock = findViewById(R.id.iv_lp_unlock);
        iv_lp_hangUp = findViewById(R.id.iv_lp_hangUp);
        tv_lp_hangUp = findViewById(R.id.tv_lp_hangUp);
        rl_lp_hangUpAll = findViewById(R.id.rl_lp_hangUp_all);
        iv_lp_hangUpAll = findViewById(R.id.iv_lp_hangUp_all);
        tv_lp_hangUpAll = findViewById(R.id.tv_lp_hangUp_all);
        iv_lp_answer = findViewById(R.id.iv_lp_answer);
        tv_lp_answer = findViewById(R.id.tv_lp_answer);
        rl_lp_answerView = findViewById(R.id.rl_lp_answerView);
@@ -184,6 +202,8 @@
        tv_lp_hangUp.setOnClickListener(this);
        iv_lp_answer.setOnClickListener(this);
        tv_lp_answer.setOnClickListener(this);
        iv_lp_hangUpAll.setOnClickListener(this);
        tv_lp_hangUpAll.setOnClickListener(this);
    }
    /**
@@ -207,7 +227,6 @@
     * 初始化开锁屏蔽倒计时
     */
    void initCountDownTimer() {
        mCountDownTimer = new CountDownTimer(10 * 1000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
@@ -220,12 +239,40 @@
             */
            @Override
            public void onFinish() {
//                showToast("开锁onFinish");
                iv_lp_unlock.setEnabled(true);
            }
        };
//
    }
    /**
     * 初始化接听计时器
     */
    void initMissedCallsTimer() {
        mMissedCallsTimer = new CountDownTimer(HDLLinphoneKit.getInstance().missedCallsTime * 1000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                if (!HDLLinphoneReverseCallActivity.this.isFinishing()) {
                    if(isAnswer){
                        mMissedCallsTimer.cancel();
                        mMissedCallsTimer = null;
                    }
                }
            }
            /**
             *倒计时结束后调用的
             */
            @Override
            public void onFinish() {
                if (!HDLLinphoneReverseCallActivity.this.isFinishing()) {
                    if (!isAnswer) {
                        isAnswer = true;
                        HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener().onMissedCallsAction();
                        finish();
                    }
                }
            }
        };
    }
    @Override
@@ -243,6 +290,9 @@
        } else if (id == R.id.iv_lp_answer || id == R.id.tv_lp_answer) {
            //接听
            onClickAnswer();
        } else if (id == R.id.iv_lp_hangUp_all || id == R.id.tv_lp_hangUp_all) {
            //全部挂断
            onClickHangUpAll();
        }
    }
@@ -320,6 +370,20 @@
    }
    /**
     * 全部挂断点击事件
     */
    private void onClickHangUpAll() {
        //1.挂断
        HDLLinphoneKit.getInstance().hangUp();
        //2.回调事件
        if (HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener() != null) {
            HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener().onCallAllRejection();
        }
        //3.页面关闭
        finish();
    }
    /**
     * 接听按钮点击事件
     */
    private void onClickAnswer() {
@@ -337,6 +401,7 @@
        tv_lp_hangUp.setText(getString(R.string.lp_hangupStr));
        setViewGone(rl_lp_answerView);
        setViewGone(tv_lp_calltime);
        setViewGone(rl_lp_hangUpAll);
        setViewVisible(timer_lp_calltime);
        startCallTimeCountdown();
        //接听通知