|
@@ -1,8 +1,15 @@
|
|
package com.wdkl.ncs.android.component.nursehome.activity
|
|
package com.wdkl.ncs.android.component.nursehome.activity
|
|
|
|
|
|
|
|
+import android.content.BroadcastReceiver
|
|
|
|
+import android.content.Context
|
|
|
|
+import android.content.Intent
|
|
|
|
+import android.content.IntentFilter
|
|
|
|
+import android.nfc.NfcAdapter
|
|
|
|
+import android.nfc.Tag
|
|
import android.support.v7.widget.RecyclerView
|
|
import android.support.v7.widget.RecyclerView
|
|
import android.support.v7.widget.helper.ItemTouchHelper
|
|
import android.support.v7.widget.helper.ItemTouchHelper
|
|
import android.util.Log
|
|
import android.util.Log
|
|
|
|
+import android.view.KeyEvent
|
|
import android.view.View
|
|
import android.view.View
|
|
import com.alibaba.android.vlayout.VirtualLayoutManager
|
|
import com.alibaba.android.vlayout.VirtualLayoutManager
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
@@ -10,6 +17,7 @@ import com.wdkl.ncs.android.component.nursehome.R
|
|
import com.wdkl.ncs.android.component.nursehome.adapter.IncomingCallAdapter
|
|
import com.wdkl.ncs.android.component.nursehome.adapter.IncomingCallAdapter
|
|
import com.wdkl.ncs.android.component.nursehome.databinding.LockScreenActivityBinding
|
|
import com.wdkl.ncs.android.component.nursehome.databinding.LockScreenActivityBinding
|
|
import com.wdkl.ncs.android.component.nursehome.launch.NurseHomeLaunch
|
|
import com.wdkl.ncs.android.component.nursehome.launch.NurseHomeLaunch
|
|
|
|
+import com.wdkl.ncs.android.component.nursehome.settingconfig.SettingConfig
|
|
import com.wdkl.ncs.android.component.nursehome.util.*
|
|
import com.wdkl.ncs.android.component.nursehome.util.*
|
|
import com.wdkl.ncs.android.lib.base.BaseActivity
|
|
import com.wdkl.ncs.android.lib.base.BaseActivity
|
|
import com.wdkl.ncs.android.lib.base.BaseApplication
|
|
import com.wdkl.ncs.android.lib.base.BaseApplication
|
|
@@ -20,6 +28,7 @@ import com.wdkl.ncs.android.middleware.logic.presenter.nursehome.DevicePresenter
|
|
import com.wdkl.ncs.android.middleware.model.PhoneBookItem
|
|
import com.wdkl.ncs.android.middleware.model.PhoneBookItem
|
|
import com.wdkl.ncs.android.middleware.model.vo.ClerkVO
|
|
import com.wdkl.ncs.android.middleware.model.vo.ClerkVO
|
|
import com.wdkl.ncs.android.middleware.model.vo.NurseDeviceInfoVO
|
|
import com.wdkl.ncs.android.middleware.model.vo.NurseDeviceInfoVO
|
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.channel.DeviceChannel
|
|
import com.wdkl.ncs.android.middleware.utils.MessageEvent
|
|
import com.wdkl.ncs.android.middleware.utils.MessageEvent
|
|
import kotlinx.android.synthetic.main.lock_screen_activity.*
|
|
import kotlinx.android.synthetic.main.lock_screen_activity.*
|
|
import org.greenrobot.eventbus.EventBus
|
|
import org.greenrobot.eventbus.EventBus
|
|
@@ -27,10 +36,15 @@ import org.greenrobot.eventbus.Subscribe
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
import serialporttest.utils.StringUtils
|
|
import serialporttest.utils.StringUtils
|
|
|
|
|
|
-class LockScreenActivity : BaseActivity<DevicePresenter, LockScreenActivityBinding>(), DeviceContract.View, IncomingCallAdapter.UpdateCallback {
|
|
|
|
|
|
+class LockScreenActivity : BaseActivity<DevicePresenter, LockScreenActivityBinding>(), DeviceContract.View,
|
|
|
|
+ IncomingCallAdapter.UpdateCallback, NfcUtils.OnReadFromNdefListener {
|
|
val TAG = LockScreenActivity::class.java.simpleName
|
|
val TAG = LockScreenActivity::class.java.simpleName
|
|
|
|
|
|
private var incomingCallAdapter: IncomingCallAdapter? = null
|
|
private var incomingCallAdapter: IncomingCallAdapter? = null
|
|
|
|
+ private var hookoffTime: Long = 0
|
|
|
|
+ private var hookonTime: Long = 0
|
|
|
|
+
|
|
|
|
+ private var nfcTagBroadcastReceiver: BroadcastReceiver? = null
|
|
|
|
|
|
override fun getLayId(): Int {
|
|
override fun getLayId(): Int {
|
|
return R.layout.lock_screen_activity
|
|
return R.layout.lock_screen_activity
|
|
@@ -45,6 +59,28 @@ class LockScreenActivity : BaseActivity<DevicePresenter, LockScreenActivityBindi
|
|
lock_incoming_call_list.layoutManager = VirtualLayoutManager(activity)
|
|
lock_incoming_call_list.layoutManager = VirtualLayoutManager(activity)
|
|
lock_incoming_call_list.adapter = incomingCallAdapter
|
|
lock_incoming_call_list.adapter = incomingCallAdapter
|
|
|
|
|
|
|
|
+ NfcUtils.getInstance().setReadNdefListener(this)
|
|
|
|
+
|
|
|
|
+ nfcTagBroadcastReceiver = object : BroadcastReceiver() {
|
|
|
|
+ override fun onReceive(context: Context, intent: Intent) {
|
|
|
|
+ try {
|
|
|
|
+ Log.d(TAG, "收到NFC广播")
|
|
|
|
+ val tag: Tag? = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)
|
|
|
|
+ val hexNo = StringUtils.bytesToHex(tag?.getId())
|
|
|
|
+ val decNo = StringUtils.bytesToTenNum(hexNo)
|
|
|
|
+
|
|
|
|
+ Log.d(TAG, "nfc hexNo: $hexNo, decNo: $decNo")
|
|
|
|
+ checkClerkValid(hexNo)
|
|
|
|
+
|
|
|
|
+ //val s: String = NfcUtils.getInstance().readMifareClassic(intent)
|
|
|
|
+ //Log.i(TAG, "NFC 卡数据: $s")
|
|
|
|
+ } catch (e: Exception) {
|
|
|
|
+ e.printStackTrace()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ registerReceiver(nfcTagBroadcastReceiver, IntentFilter("NFC_DISCOVERYED"))
|
|
|
|
+
|
|
val touchCallback: ItemTouchHelper.Callback =
|
|
val touchCallback: ItemTouchHelper.Callback =
|
|
object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT) {
|
|
object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT) {
|
|
override fun onMove(
|
|
override fun onMove(
|
|
@@ -101,6 +137,20 @@ class LockScreenActivity : BaseActivity<DevicePresenter, LockScreenActivityBindi
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override fun onResume() {
|
|
|
|
+ super.onResume()
|
|
|
|
+
|
|
|
|
+ if (NfcUtils.getInstance().isNfcEnabled) {
|
|
|
|
+ NfcUtils.getInstance().NfcOnResume(this)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onPause() {
|
|
|
|
+ super.onPause()
|
|
|
|
+
|
|
|
|
+ NfcUtils.getInstance().clear(this)
|
|
|
|
+ }
|
|
|
|
+
|
|
override fun onStop() {
|
|
override fun onStop() {
|
|
super.onStop()
|
|
super.onStop()
|
|
|
|
|
|
@@ -109,6 +159,10 @@ class LockScreenActivity : BaseActivity<DevicePresenter, LockScreenActivityBindi
|
|
|
|
|
|
override fun destory() {
|
|
override fun destory() {
|
|
Constants.showLock = false
|
|
Constants.showLock = false
|
|
|
|
+
|
|
|
|
+ if (nfcTagBroadcastReceiver != null) {
|
|
|
|
+ unregisterReceiver(nfcTagBroadcastReceiver)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override fun onBackPressed() {
|
|
override fun onBackPressed() {
|
|
@@ -153,6 +207,52 @@ class LockScreenActivity : BaseActivity<DevicePresenter, LockScreenActivityBindi
|
|
//
|
|
//
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //大朝华15.6寸主机按键监听
|
|
|
|
+ override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
|
|
|
+ Log.d(TAG, "keyDown ====> keyCode: $keyCode, action: ${event?.action}")
|
|
|
|
+ if (keyCode == 135 || keyCode == 139) {
|
|
|
|
+ //手柄拿起
|
|
|
|
+ Constants.hookOn = false
|
|
|
|
+ VoiceManagerUtil.setCallVoice(activity, SettingConfig.getHostCallVolume(activity))
|
|
|
|
+
|
|
|
|
+ if (System.currentTimeMillis() - hookoffTime > 2000) {
|
|
|
|
+ if (Constants.CALL_STATE == Constants.CALL_STANDBY) {
|
|
|
|
+ //不是呼出也不是通话状态则接听电话
|
|
|
|
+ EventBus.getDefault().post(MessageEvent("hookoff", Constants.EVENT_HOOK_OFF))
|
|
|
|
+ } else if (Constants.CALL_STATE == Constants.CALL_VISITING || Constants.CALL_STATE == Constants.CALL_V_INCOMING) {
|
|
|
|
+ EventBus.getDefault().post(MessageEvent("hookoff", Constants.EVENT_V_HOOK_OFF))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ EventBus.getDefault().post(MessageEvent(false, Constants.EVENT_TOGGLE_SPEAKER))
|
|
|
|
+ VoiceManagerUtil.switchAudioMode(activity, false)
|
|
|
|
+ hookoffTime = System.currentTimeMillis()
|
|
|
|
+ } else if (keyCode == 134 || keyCode == 138) {
|
|
|
|
+ //手柄放下
|
|
|
|
+ Constants.hookOn = true
|
|
|
|
+ VoiceManagerUtil.setCallVoice(activity, SettingConfig.getHostCallVolume(activity))
|
|
|
|
+
|
|
|
|
+ if (System.currentTimeMillis() - hookonTime > 2000) {
|
|
|
|
+ if (Constants.CALL_STATE == Constants.CALL_OUTGOING) {
|
|
|
|
+ //呼出取消
|
|
|
|
+ Constants.CALL_STATE = Constants.CALL_STANDBY
|
|
|
|
+ DeviceChannel.calling = false
|
|
|
|
+ EventBus.getDefault().post(MessageEvent("cancel", Constants.EVENT_END_CALL))
|
|
|
|
+ } else if (Constants.CALL_STATE == Constants.CALL_CALLING) {
|
|
|
|
+ Constants.CALL_STATE = Constants.CALL_STANDBY
|
|
|
|
+ DeviceChannel.calling = false
|
|
|
|
+ EventBus.getDefault().post(MessageEvent("handoff", Constants.EVENT_END_CALL))
|
|
|
|
+ }
|
|
|
|
+ EventBus.getDefault().post(MessageEvent("hookon", Constants.EVENT_HOOK_ON))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ EventBus.getDefault().post(MessageEvent(true, Constants.EVENT_TOGGLE_SPEAKER))
|
|
|
|
+ VoiceManagerUtil.switchAudioMode(activity, true)
|
|
|
|
+ hookonTime = System.currentTimeMillis()
|
|
|
|
+ }
|
|
|
|
+ return super.onKeyDown(keyCode, event)
|
|
|
|
+ }
|
|
|
|
+
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
fun onMoonEvent(messageEvent: MessageEvent) {
|
|
fun onMoonEvent(messageEvent: MessageEvent) {
|
|
when (messageEvent.getType()) {
|
|
when (messageEvent.getType()) {
|
|
@@ -171,13 +271,17 @@ class LockScreenActivity : BaseActivity<DevicePresenter, LockScreenActivityBindi
|
|
val decNo = StringUtils.bytesToTenNum(hexNo)
|
|
val decNo = StringUtils.bytesToTenNum(hexNo)
|
|
|
|
|
|
Log.d(TAG, "nfc hexNo: $hexNo, decNo: $decNo, lock screen focused: " + hasWindowFocus())
|
|
Log.d(TAG, "nfc hexNo: $hexNo, decNo: $decNo, lock screen focused: " + hasWindowFocus())
|
|
- if (hasWindowFocus()) {
|
|
|
|
- presenter.checkClerk(Constants.part_id, hexNo)
|
|
|
|
- }
|
|
|
|
|
|
+ checkClerkValid(hexNo)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun checkClerkValid(hexNo: String) {
|
|
|
|
+ if (hasWindowFocus()) {
|
|
|
|
+ presenter.checkClerk(Constants.part_id, hexNo)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
override fun onUpdateCalls() {
|
|
override fun onUpdateCalls() {
|
|
if (Constants.callingList.size == 0) {
|
|
if (Constants.callingList.size == 0) {
|
|
ll_incoming_call.visibility = View.GONE
|
|
ll_incoming_call.visibility = View.GONE
|
|
@@ -185,4 +289,14 @@ class LockScreenActivity : BaseActivity<DevicePresenter, LockScreenActivityBindi
|
|
ll_incoming_call.visibility = View.VISIBLE
|
|
ll_incoming_call.visibility = View.VISIBLE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ override fun Readsuccessfully(id: String?) {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun readFail() {
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ showMessage("NFC read fail")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|