| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | private String deviceSipAccount;//设备SIP账号 |
| | | private boolean enableVideo = false; |
| | | |
| | | private CountDownTimer mMissedCallsTimer; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | |
| | | initCountDownTimer(); |
| | | initLinphone(); |
| | | // initVibrator(); |
| | | initMissedCallsTimer(); |
| | | mMissedCallsTimer.start(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * onDestroy |
| | |
| | | mCountDownTimer.cancel(); |
| | | mCountDownTimer = null; |
| | | } |
| | | if (mMissedCallsTimer != null) { |
| | | mMissedCallsTimer.cancel(); |
| | | mMissedCallsTimer = null; |
| | | } |
| | | onDestroyLinphone(); |
| | | HDLLog.i(TAG, "onDestroy"); |
| | | } |
| | |
| | | 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); |
| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 初始化开锁屏蔽倒计时 |
| | | */ |
| | | void initCountDownTimer() { |
| | | |
| | | mCountDownTimer = new CountDownTimer(10 * 1000, 1000) { |
| | | @Override |
| | | public void onTick(long millisUntilFinished) { |
| | |
| | | */ |
| | | @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 |
| | |
| | | } 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(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 全部挂断点击事件 |
| | | */ |
| | | private void onClickHangUpAll() { |
| | | //1.挂断 |
| | | HDLLinphoneKit.getInstance().hangUp(); |
| | | //2.回调事件 |
| | | if (HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener() != null) { |
| | | HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener().onCallAllRejection(); |
| | | } |
| | | //3.页面关闭 |
| | | finish(); |
| | | } |
| | | |
| | | /** |
| | | * 接听按钮点击事件 |
| | | */ |
| | | private void onClickAnswer() { |
| | |
| | | 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(); |
| | | //接听通知 |