1.修复消息全部已读页面不更新bug
2.优化直播雷达开灯加载动画变大问题 3.led设置页面重新编写逻辑 4.蓝牙绑定指令增加上位机类型和绑定密钥 5.map页新增睡眠显示 6.信用卡页面,输入名字默认全大写 7.Wifi zone 内,地址显示为“Home · xxxxx” 8.优化雷达直播LED灯按钮禁用状态
This commit is contained in:
@@ -28,9 +28,9 @@ android {
|
||||
applicationId "com.abbidot.tracker"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 35
|
||||
versionCode 2111
|
||||
// versionName "2.1.11"
|
||||
versionName "2.1.11-Beta1"
|
||||
versionCode 2112
|
||||
// versionName "2.1.12"
|
||||
versionName "2.1.12-Beta1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -38,8 +38,10 @@ class NotificationV2Activity :
|
||||
setOnItemClickListener(object : BaseRecyclerAdapter.OnItemClickListener {
|
||||
override fun onItemClick(itemView: View?, pos: Int) {
|
||||
val message = getItem(pos)
|
||||
mReadMessageId = message.messageId
|
||||
mNotificationsViewModel.setMessageIsRead(mReadMessageId)
|
||||
if (message.isRead == ConstantInt.Type0) {
|
||||
mReadMessageId = message.messageId
|
||||
mNotificationsViewModel.setMessageIsRead(mReadMessageId)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -125,7 +127,7 @@ class NotificationV2Activity :
|
||||
isRefresh = true
|
||||
}
|
||||
}
|
||||
if (isRefresh) mMessageAdapter.notifyItemChanged(0, list.size)
|
||||
if (isRefresh) mMessageAdapter.notifyItemRangeChanged(0, list.size)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.abbidot.tracker.ui.activity.device.set
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import androidx.activity.viewModels
|
||||
@@ -10,12 +8,8 @@ import androidx.core.view.isGone
|
||||
import com.abbidot.baselibrary.constant.ConState
|
||||
import com.abbidot.baselibrary.constant.EventName
|
||||
import com.abbidot.baselibrary.eventbus.XEventBus
|
||||
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
|
||||
import com.abbidot.baselibrary.util.AppUtils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.adapter.LedLightColorAdapter
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.base.BaseDialog
|
||||
import com.abbidot.tracker.bean.BleTrackDeviceBean
|
||||
import com.abbidot.tracker.bean.MapDeviceBean
|
||||
import com.abbidot.tracker.bean.PetBean
|
||||
@@ -48,16 +42,14 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
|
||||
private var mPetBean: PetBean? = null
|
||||
private var mMapDeviceBean: MapDeviceBean? = null
|
||||
private var mOldMapDeviceBean: MapDeviceBean? = null
|
||||
private var mBleTrackDeviceBean: BleTrackDeviceBean? = null
|
||||
private lateinit var mLedLightColorAdapter: LedLightColorAdapter
|
||||
private lateinit var mLedModeList: MutableList<String>
|
||||
|
||||
//防止多次按返回键执行
|
||||
private var isFinishSave = false
|
||||
|
||||
//禁用模式
|
||||
private var isDisabledMode = true
|
||||
private var mLedControlType = ConstantInt.Type0
|
||||
private var mLedSwitch = ConstantInt.Type1
|
||||
private var mLedMode = ConstantInt.Type1
|
||||
private var mLedTempMode = ConstantInt.Type1
|
||||
|
||||
override fun getTopBar() = mViewBinding.ilLedLightBar.titleTopBar
|
||||
|
||||
@@ -65,7 +57,6 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
super.initData()
|
||||
setTopBarTitle(R.string.tracker_manage_set_led)
|
||||
setLeftBackImage(R.drawable.icon_white_back_svg)
|
||||
// initStatus()
|
||||
|
||||
mPetBean = Util.getParcelableAdaptive(intent, ConstantString.Pet, PetBean::class.java)
|
||||
|
||||
@@ -86,14 +77,10 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
val builder = ViewUtil.instance.showBottomSheetList(mContext, { dialog, _, position, _ ->
|
||||
mMapDeviceBean?.apply {
|
||||
dialog.dismiss()
|
||||
ledMode = position + 1
|
||||
mViewBinding.ledLightMode.detailText = mLedModeList[position]
|
||||
mViewBinding.ledLightOpenAndClose.switch.let {
|
||||
if (!it.isChecked) {
|
||||
it.isChecked = true
|
||||
}
|
||||
setBleLedMode(ledMode)
|
||||
}
|
||||
mLedSwitch = ledSwitch
|
||||
mLedMode = ledMode
|
||||
mLedTempMode = position + 1
|
||||
setBleLedMode(mLedTempMode)
|
||||
}
|
||||
})
|
||||
for (i in 0 until mLedModeList.size) builder.addItem(mLedModeList[i])
|
||||
@@ -102,39 +89,8 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
ViewUtil.instance.showQMUICommonListItemView(mContext, this, {
|
||||
if (!isDisabledMode) builder.build().show()
|
||||
}, getString(R.string.txt_light_mode))
|
||||
// mMapDeviceBean?.apply {
|
||||
// detailText = when {
|
||||
// ledMode - 1 >= mLedModeList.size -> {
|
||||
// mLedModeList[mLedModeList.size - 1]
|
||||
// }
|
||||
//
|
||||
// ledMode == 0 -> {
|
||||
// mLedModeList[0]
|
||||
// }
|
||||
//
|
||||
// else -> mLedModeList[ledMode - 1]
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
val colorListResId = mutableListOf(
|
||||
R.color.white,
|
||||
R.color.colormenu,
|
||||
R.color.corner_color,
|
||||
R.color.blue_light,
|
||||
R.color.deep_blue,
|
||||
R.color.red_blue,
|
||||
R.color.yellow_color,
|
||||
R.color.yellow_red_color
|
||||
)
|
||||
mLedLightColorAdapter = LedLightColorAdapter(mContext, colorListResId)
|
||||
mLedLightColorAdapter.setOnItemClickListener(object :
|
||||
BaseRecyclerAdapter.OnItemClickListener {
|
||||
override fun onItemClick(itemView: View?, pos: Int) {
|
||||
setLedLightColor(ContextCompat.getColor(mContext, colorListResId[pos]))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
mViewBinding.apply {
|
||||
ViewUtil.instance.viewRotationAnimator(ilLedLightBtnState.ivLedBtnState, true)
|
||||
@@ -146,19 +102,6 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
it.tvIssueTwoSmallTwoTitle.setText(R.string.txt_network_setup)
|
||||
it.tvIssueTwoSmallTitleTwoContent.setText(R.string.txt_network_setup_dec)
|
||||
}
|
||||
ViewUtil.instance.setRecyclerViewGridLayout(
|
||||
mContext,
|
||||
colorSelectRecyclerView,
|
||||
mLedLightColorAdapter,
|
||||
spanCount = 2,
|
||||
bottom = AppUtils.dpToPx(9),
|
||||
itemWidth = AppUtils.dpToPx(30),
|
||||
offset = AppUtils.dpToPx(290)
|
||||
)
|
||||
|
||||
selectColorPaintView.setOnColorSelectListener {
|
||||
setLedLightColor(it)
|
||||
}
|
||||
|
||||
setOnClickListenerViews(
|
||||
ledLightBluetoothTips.trbBleConnectState,
|
||||
@@ -186,23 +129,59 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
val data = it.getOrNull()
|
||||
data?.apply {
|
||||
mMapDeviceBean = data
|
||||
mOldMapDeviceBean = data.copy()
|
||||
setDeviceData(data)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
mLedLightViewModel.mSetLedLightLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
showToast(R.string.txt_change_successful, isFinish = true)
|
||||
}
|
||||
mLedLightViewModel.apply {
|
||||
mLedSwitchLiveData.observe(this@LedLightActivity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
mPetBean?.apply {
|
||||
if (!SRBleUtil.instance.isMacConnect(macID)) {
|
||||
mViewBinding.ledLightOpenAndClose.switch.isChecked =
|
||||
!mViewBinding.ledLightOpenAndClose.switch.isChecked
|
||||
mMapDeviceBean?.let { m ->
|
||||
val ledSwitch = if (m.ledSwitch == ConstantInt.Open) {
|
||||
ConstantInt.Close
|
||||
} else {
|
||||
ConstantInt.Open
|
||||
}
|
||||
m.ledSwitch = ledSwitch
|
||||
}
|
||||
}
|
||||
}
|
||||
setLedControlState()
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
isFinishSave = false
|
||||
mViewBinding.btnLedLightSetSave.isEnabled = true
|
||||
}
|
||||
})
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
setLedControlState()
|
||||
}
|
||||
|
||||
override fun onErrorCode() {
|
||||
setLedControlState()
|
||||
}
|
||||
})
|
||||
}
|
||||
mSetLedLightLiveData.observe(this@LedLightActivity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
mLedMode = mLedTempMode
|
||||
mLedSwitch = ConstantInt.Type1
|
||||
mViewBinding.ledLightOpenAndClose.switch.isChecked = true
|
||||
setLedModeControlState()
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
setLedModeControlState()
|
||||
}
|
||||
|
||||
override fun onErrorCode() {
|
||||
setLedModeControlState()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//接收开蓝牙操作,然后搜索连接设备
|
||||
@@ -234,6 +213,29 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置LED可以点击状态
|
||||
*/
|
||||
private fun setLedControlState() {
|
||||
mPetBean?.apply {
|
||||
if (!SRBleUtil.instance.isMacConnect(macID)) {
|
||||
setBtnState(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setLedModeControlState() {
|
||||
mPetBean?.apply {
|
||||
if (!SRBleUtil.instance.isMacConnect(macID)) {
|
||||
setBtnState(true)
|
||||
mMapDeviceBean?.let {
|
||||
it.ledSwitch = mLedSwitch
|
||||
it.ledMode = mLedMode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseData(data: ByteArray?) {
|
||||
if (null != data && data.isNotEmpty()) {
|
||||
val data0 = SRBleCmdUtil.instance.byteToInt(data[0])
|
||||
@@ -242,26 +244,34 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
if (data0 == 3 && data1 == 1) {
|
||||
val data3 = SRBleCmdUtil.instance.byteToInt(data[3])
|
||||
val ledSwitch = if (data3 > 0) {
|
||||
mLedMode = data3
|
||||
mViewBinding.ledLightOpenAndClose.switch.isChecked = true
|
||||
ConstantInt.Open
|
||||
} else {
|
||||
mViewBinding.ledLightOpenAndClose.switch.isChecked = false
|
||||
ConstantInt.Close
|
||||
}
|
||||
mMapDeviceBean?.ledSwitch = ledSwitch
|
||||
|
||||
val modeType = if (data2 == 0) {
|
||||
ConstantInt.Type1
|
||||
} else {
|
||||
ConstantInt.Type3
|
||||
}
|
||||
mMapDeviceBean?.let {
|
||||
mViewBinding.ledLightOpenAndClose.accessoryType =
|
||||
QMUICommonListItemView.ACCESSORY_TYPE_SWITCH
|
||||
mViewBinding.ilLedLightBtnState.root.visibility = View.GONE
|
||||
//远程控制
|
||||
mLedLightViewModel.setLedSwitch(
|
||||
null, it.deviceServerId, ledSwitch, modeType
|
||||
)
|
||||
it.ledSwitch = ledSwitch
|
||||
setBtnState(true)
|
||||
//控制开关
|
||||
if (mLedControlType == ConstantInt.Type0) {
|
||||
//远程控制
|
||||
mLedLightViewModel.setLedSwitch(
|
||||
null, it.deviceServerId, ledSwitch, modeType
|
||||
)
|
||||
} else {
|
||||
//控制模式
|
||||
it.ledMode = data3
|
||||
//远程控制
|
||||
mLedLightViewModel.setLedLight(this@LedLightActivity, it, modeType)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,12 +279,11 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
|
||||
private fun setDeviceData(mapDeviceBean: MapDeviceBean) {
|
||||
mapDeviceBean.apply {
|
||||
mLedMode=ledMode
|
||||
mLedSwitch=ledSwitch
|
||||
mViewBinding.let {
|
||||
it.ledLightOpenAndClose.switch.isChecked = ledSwitch == ConstantInt.Open
|
||||
|
||||
setLedLightColor(
|
||||
Color.rgb(ledRedValue, ledGreenValue, ledBlueValue), true
|
||||
)
|
||||
if (ledMode == 0 || ledMode > mLedModeList.size) ledMode = 1
|
||||
it.ledLightMode.detailText = mLedModeList[ledMode - 1]
|
||||
|
||||
@@ -285,7 +294,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
|
||||
private fun updateDisabledState(mapDeviceBean: MapDeviceBean) {
|
||||
mapDeviceBean.apply {
|
||||
setDisabledState(!Util.getLedControlState(deviceMacId,mapDeviceBean))
|
||||
setDisabledState(!Util.getLedControlState(deviceMacId, mapDeviceBean))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +306,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
ledLightBluetoothTips.root.visibility = View.GONE
|
||||
R.color.grey_color
|
||||
} else {
|
||||
btnLedLightSetSave.visibility = View.VISIBLE
|
||||
btnLedLightSetSave.visibility = View.GONE
|
||||
ledLightBluetoothTips.root.visibility = View.VISIBLE
|
||||
R.color.qmui_config_color_gray_1
|
||||
}
|
||||
@@ -309,8 +318,9 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
/**
|
||||
* 更新设备连接状态
|
||||
*/
|
||||
private fun updateConState(trackBleDevice: BleTrackDeviceBean, isShowToast: Boolean = true) {
|
||||
mBleTrackDeviceBean = trackBleDevice
|
||||
private fun updateConState(
|
||||
trackBleDevice: BleTrackDeviceBean, isShowToast: Boolean = true
|
||||
) {
|
||||
mViewBinding.ledLightBluetoothTips.trbBleConnectState.let { view ->
|
||||
val bgColor = if (trackBleDevice.conState == ConState.CONNECTED) {
|
||||
view.text = getString(R.string.tracker_manage_set_ble_connect)
|
||||
@@ -327,105 +337,23 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
}
|
||||
|
||||
private fun setBleLedMode(mode: Int) {
|
||||
mBleTrackDeviceBean?.apply {
|
||||
SRBleUtil.instance.setBleLedSwitch(mContext, bleDevice, mode)
|
||||
}
|
||||
}
|
||||
|
||||
override fun leftBackOnClick() {
|
||||
if (null == mMapDeviceBean || null == mOldMapDeviceBean) {
|
||||
super.leftBackOnClick()
|
||||
return
|
||||
}
|
||||
if (isFinishSave) return
|
||||
//是否是蓝牙连接了,修改设备数据返回,同步服务器
|
||||
if (null != mBleTrackDeviceBean) {
|
||||
mMapDeviceBean?.apply {
|
||||
mOldMapDeviceBean?.let {
|
||||
if (it == mMapDeviceBean) {
|
||||
super.leftBackOnClick()
|
||||
} else {
|
||||
//判断是否有蓝牙连接
|
||||
if (BleManager.getInstance().isConnected(mBleTrackDeviceBean!!.bleDevice)) {
|
||||
finishAndSave(ConstantInt.Type1)
|
||||
} else {
|
||||
super.leftBackOnClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.leftBackOnClick()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存设置数据
|
||||
*/
|
||||
private fun finishAndSave(modeType: Int) {
|
||||
if (null == mMapDeviceBean) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
mMapDeviceBean?.apply {
|
||||
isFinishSave = true
|
||||
mLedLightViewModel.setLedLight(this@LedLightActivity, this, modeType)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param show 只显示,不作为命令处理
|
||||
*/
|
||||
private fun setLedLightColor(color: Int, show: Boolean = false) {
|
||||
val drawableColor = ColorDrawable(color)
|
||||
mViewBinding.currentSelectColor.appHeadImage.setImageDrawable(drawableColor)
|
||||
// mViewBinding.ledLightBarColorImage.setBackgroundColor(color)
|
||||
|
||||
val red = color and 0xff0000 shr 16
|
||||
val green = color and 0x00ff00 shr 8
|
||||
val blue = color and 0x0000ff
|
||||
|
||||
mMapDeviceBean?.apply {
|
||||
ledRedValue = red
|
||||
ledGreenValue = green
|
||||
ledBlueValue = blue
|
||||
}
|
||||
|
||||
// mViewBinding.tvLedLightCurrentRgb.text = String.format("#%06X", -0x1 and color)
|
||||
mViewBinding.tvLedLightCurrentRgb.text = String.format("#%06X", 0xffffff and color)
|
||||
|
||||
if (!show) {
|
||||
mBleTrackDeviceBean?.let {
|
||||
//判断是否有蓝牙连接
|
||||
if (BleManager.getInstance().isConnected(it.bleDevice)) {
|
||||
SRBleUtil.instance.writeData(
|
||||
it.bleDevice, SRBleCmdUtil.instance.ledColor(
|
||||
SRBleCmdUtil.CMD_WRITE, red, green, blue
|
||||
)
|
||||
)
|
||||
mLedControlType = ConstantInt.Type1
|
||||
setBtnState(false)
|
||||
if (BleManager.getInstance().isConnected(deviceMacId)) {
|
||||
//蓝牙控制
|
||||
SRBleUtil.instance.getConnectMacDevice(deviceMacId)?.let {
|
||||
SRBleUtil.instance.setBleLedSwitch(mContext, it.bleDevice, mode)
|
||||
}
|
||||
} else {
|
||||
//远程控制
|
||||
ledMode = mode
|
||||
ledSwitch = ConstantInt.Open
|
||||
mLedLightViewModel.setLedLight(this@LedLightActivity, this, ConstantInt.Type2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开连接设备
|
||||
*/
|
||||
private fun operateDeviceTips(messageID: Int, type: Int = 0) {
|
||||
ViewUtil.instance.showDialog(mContext, messageID, object : BaseDialog.OnDialogOkListener {
|
||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
dialog.dismiss()
|
||||
when (type) {
|
||||
0 -> {
|
||||
mBleTrackDeviceBean?.let {
|
||||
mConnectionDeviceViewModel.disconnect(it.bleDevice)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, okTextResId = R.string.start_txt_yes)
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动连接/断开设备
|
||||
*/
|
||||
@@ -454,45 +382,61 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
}
|
||||
}
|
||||
|
||||
private fun setLedSwitch() {
|
||||
mViewBinding.ledLightOpenAndClose.switch.apply {
|
||||
mMapDeviceBean?.let {
|
||||
mViewBinding.ledLightOpenAndClose.accessoryType =
|
||||
QMUICommonListItemView.ACCESSORY_TYPE_NONE
|
||||
mViewBinding.ilLedLightBtnState.root.visibility = View.VISIBLE
|
||||
val ledSwitch = if (it.ledSwitch == ConstantInt.Open) {
|
||||
ConstantInt.Close
|
||||
} else {
|
||||
ConstantInt.Open
|
||||
}
|
||||
if (BleManager.getInstance().isConnected(it.deviceMacId)) {
|
||||
//蓝牙控制
|
||||
mBleTrackDeviceBean?.apply {
|
||||
SRBleUtil.instance.setBleLedSwitch(mContext, bleDevice, ledSwitch)
|
||||
}
|
||||
} else {
|
||||
//远程控制
|
||||
mLedLightViewModel.setLedSwitch(
|
||||
null, it.deviceServerId, ledSwitch, ConstantInt.Type2
|
||||
)
|
||||
}
|
||||
private fun setBtnState(setEnabled: Boolean) {
|
||||
mViewBinding.apply {
|
||||
if (setEnabled) {
|
||||
ledLightMode.detailText = mLedModeList[mLedMode - 1]
|
||||
ledLightMode.isEnabled = true
|
||||
lvLedLightModeLoading.visibility = View.GONE
|
||||
ledLightOpenAndClose.accessoryType = QMUICommonListItemView.ACCESSORY_TYPE_SWITCH
|
||||
ilLedLightBtnState.root.visibility = View.GONE
|
||||
} else {
|
||||
ledLightMode.detailText = ""
|
||||
ledLightMode.isEnabled = false
|
||||
lvLedLightModeLoading.visibility = View.VISIBLE
|
||||
ledLightOpenAndClose.accessoryType = QMUICommonListItemView.ACCESSORY_TYPE_NONE
|
||||
ilLedLightBtnState.root.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setLedSwitch() {
|
||||
mMapDeviceBean?.apply {
|
||||
mLedControlType = ConstantInt.Type0
|
||||
mViewBinding.ledLightOpenAndClose.switch.isChecked =
|
||||
!mViewBinding.ledLightOpenAndClose.switch.isChecked
|
||||
setBtnState(false)
|
||||
val ledSwitch = if (ledSwitch == ConstantInt.Open) {
|
||||
ConstantInt.Close
|
||||
} else {
|
||||
ConstantInt.Open
|
||||
}
|
||||
if (BleManager.getInstance().isConnected(deviceMacId)) {
|
||||
//蓝牙控制
|
||||
SRBleUtil.instance.getConnectMacDevice(deviceMacId)?.let {
|
||||
SRBleUtil.instance.setBleLedSwitch(mContext, it.bleDevice, ledSwitch)
|
||||
}
|
||||
} else {
|
||||
//远程控制
|
||||
mLedLightViewModel.setLedSwitch(
|
||||
null, deviceServerId, ledSwitch, ConstantInt.Type2
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// val modeType = if (null != mBleTrackDeviceBean && BleManager.getInstance()
|
||||
// .isConnected(mBleTrackDeviceBean!!.bleDevice)
|
||||
// ) ConstantInt.Type1
|
||||
// else ConstantInt.Type2
|
||||
// btnLedLightSetSave.isEnabled = false
|
||||
// finishAndSave(modeType)
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
mViewBinding.apply {
|
||||
when (v) {
|
||||
//手动连接设备
|
||||
ledLightBluetoothTips.trbBleConnectState -> connectionBtn(ledLightBluetoothTips.trbBleConnectState.text.toString())
|
||||
btnLedLightSetSave -> {
|
||||
val modeType = if (null != mBleTrackDeviceBean && BleManager.getInstance()
|
||||
.isConnected(mBleTrackDeviceBean!!.bleDevice)
|
||||
) ConstantInt.Type1
|
||||
else ConstantInt.Type2
|
||||
btnLedLightSetSave.isEnabled = false
|
||||
finishAndSave(modeType)
|
||||
}
|
||||
|
||||
btnLedLightIssue -> showLedIssue()
|
||||
ilLedLightIssueLayout.tvCloseIssueBtn -> showLedIssue()
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.abbidot.tracker.ui.activity.map
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.Typeface
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
@@ -292,7 +295,6 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
|
||||
override fun onResult(any: Any) {
|
||||
val data = it.getOrNull()
|
||||
data?.let { d ->
|
||||
LogUtil.e("xxxxxxxxxxxxxxxxxxxxx,${d.latitude},${d.longitude}")
|
||||
d.isCloseBattery = isCloseBattery
|
||||
d.isCloseMsg = isCloseMsg
|
||||
mMapDeviceBean = d
|
||||
@@ -400,6 +402,17 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
|
||||
}
|
||||
mMapDeviceBean?.apply {
|
||||
if (trackBle.mac == deviceMacId) {
|
||||
//蓝牙连接断开更快更新状态
|
||||
mMapViewModel.setDeviceStateAndWarningData(
|
||||
mContext,
|
||||
mPetBean,
|
||||
this,
|
||||
mViewBinding.ilLiveV3MapDeviceMsg.root,
|
||||
mViewBinding.ilLiveV3MapDeviceMsg.tvDeviceMsgContent,
|
||||
mViewBinding.ilLiveV3MapDeviceMsg.ivDeviceMsgCloseBtn,
|
||||
mDeviceStateList,
|
||||
mDeviceStateAdapter
|
||||
)
|
||||
updateConState(trackBle)
|
||||
//分享设备不可以控制灯
|
||||
if (p.shared == ConstantInt.NoShare) {
|
||||
@@ -848,6 +861,23 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
|
||||
|
||||
private fun setLedBtnEnabled(btnEnabled: Boolean) {
|
||||
mViewBinding.apply {
|
||||
ilLiveV2BluetoothFindDevice.ilLiveV2RadarLightSwitch.tvDeviceLightSwitchTitle.let {
|
||||
val tColor = if (btnEnabled) {
|
||||
R.color.data_black_color
|
||||
} else {
|
||||
R.color.grey_color
|
||||
}
|
||||
val cColor = ContextCompat.getColor(mContext, tColor)
|
||||
// 假设只给左侧图标 tint
|
||||
val drawables = ContextCompat.getDrawable(mContext, R.drawable.icon_light_svg)
|
||||
drawables?.let { d ->
|
||||
val wrappedDrawable = DrawableCompat.wrap(d)
|
||||
DrawableCompat.setTint(wrappedDrawable, cColor)
|
||||
DrawableCompat.setTintMode(wrappedDrawable, PorterDuff.Mode.SRC_IN)
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null)
|
||||
}
|
||||
it.setTextColor(cColor)
|
||||
}
|
||||
ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.cbDeviceLightSwitch.isEnabled = btnEnabled
|
||||
ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.root.isEnabled = btnEnabled
|
||||
ilLiveV2BluetoothFindDevice.ilLiveV2RadarLightSwitch.root.isEnabled = btnEnabled
|
||||
|
||||
@@ -57,6 +57,7 @@ class AddCreditCardPaymentActivity :
|
||||
|
||||
ilAddCardNameOnCard.let {
|
||||
it.tvInputView2NameTitle.setText(R.string.txt_name_card)
|
||||
it.etInputView2Content.setFilters(arrayOf<InputFilter>(InputFilter.AllCaps()))
|
||||
it.etInputView2Content.onFocusChangeListener = this@AddCreditCardPaymentActivity
|
||||
showEditViewContent(it.etInputView2Content, mCreditCard!!.cardName)
|
||||
}
|
||||
|
||||
@@ -386,8 +386,7 @@ class HomeTrackFragment :
|
||||
}
|
||||
mLedLightViewModel.mLedSwitchLiveData.observe(viewLifecycleOwner) {
|
||||
dealRequestResult(
|
||||
it,
|
||||
object : GetResultCallback {
|
||||
it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
getHomeV2Activity()?.let { h ->
|
||||
h.getPet(false)?.let { p ->
|
||||
@@ -415,13 +414,21 @@ class HomeTrackFragment :
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
setLedErrorState()
|
||||
}
|
||||
},
|
||||
isRequestErrorTip = mLedMac == getHomeV2Activity()!!.getPet(false)!!.macID,
|
||||
isShowCodeError = mLedMac == getHomeV2Activity()!!.getPet(false)!!.macID
|
||||
}, isRequestErrorTip = getShowError(), isShowCodeError = getShowError()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getShowError(): Boolean {
|
||||
var showCodeError = false
|
||||
getHomeV2Activity()?.apply {
|
||||
getPet(false)?.let {
|
||||
showCodeError = mLedMac == it.macID
|
||||
}
|
||||
}
|
||||
return showCodeError
|
||||
}
|
||||
|
||||
private fun setLedErrorState() {
|
||||
getHomeV2Activity()?.apply {
|
||||
getPet(false)?.let {
|
||||
|
||||
@@ -830,6 +830,9 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
getPet()?.let { pet ->
|
||||
if (SRBleUtil.instance.isMacConnect(pet.macID)) {
|
||||
showToast(R.string.txt_pet_close, gravity = Gravity.CENTER)
|
||||
} else if (null != mMapDeviceBean && mMapDeviceBean!!.powerSwitch == ConstantInt.Type2) {
|
||||
val string = String.format(getString(R.string.txt_move_wake), pet.petName)
|
||||
showToast(string, gravity = Gravity.CENTER)
|
||||
} else if (!isCanLive) {
|
||||
showToast(R.string.txt_locate_works, gravity = Gravity.CENTER)
|
||||
} else if (!isNotifyRefreshLocation) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.bean.HistoryDataBean
|
||||
import com.abbidot.tracker.bean.MapDeviceBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.databinding.LayoutPetLocationInfoBinding
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
@@ -99,7 +100,11 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
||||
// mMarker?.tag = history
|
||||
|
||||
// showMarkerInfoWindow(history)
|
||||
val address = String.format(mContext!!.getString(R.string.txt_near), it)
|
||||
val address = if (inWifiZone == ConstantInt.Type1) {
|
||||
mContext!!.getString(R.string.txt_home) + " · $it"
|
||||
} else {
|
||||
String.format(mContext!!.getString(R.string.txt_near), it)
|
||||
}
|
||||
ViewUtil.instance.viewShow(mPetLocationLayoutBinding.root)
|
||||
mPetLocationLayoutBinding.let { layout ->
|
||||
layout.tvPetLocationReverseGeocode.text = address
|
||||
|
||||
@@ -146,7 +146,7 @@ class SRBleCmdUtil private constructor() {
|
||||
* 绑定设备
|
||||
*/
|
||||
fun bindDevice(): ByteArray {
|
||||
val byteArray = byteArrayOf(0x01, CMD_WRITE.toByte())
|
||||
val byteArray = byteArrayOf(0x01, CMD_WRITE.toByte(),0x02,0,0)
|
||||
return getCrc8Cmd(byteArray)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.abbidot.tracker.widget.TypefaceButton
|
||||
import com.abbidot.tracker.widget.TypefaceTextView
|
||||
import com.clj.fastble.BleManager
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class MapViewModel : ViewModel() {
|
||||
|
||||
@@ -447,7 +448,16 @@ class MapViewModel : ViewModel() {
|
||||
batteryText.let {
|
||||
canShowBattery = true
|
||||
rootView.visibility = View.VISIBLE
|
||||
if (powerSwitch == ConstantInt.Type0) {
|
||||
if (powerSwitch == ConstantInt.Type2) {
|
||||
//R.drawable.icon_weak_gps_image
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.icon_device_sleep_image, 0, 0, 0
|
||||
)
|
||||
it.text = String.format(
|
||||
context.getString(R.string.txt_fully_asleep), forTime(updateTime)
|
||||
)
|
||||
ViewUtil.instance.viewShow(closeBtn)
|
||||
} else if (powerSwitch == ConstantInt.Type0) {
|
||||
//连接蓝牙就不显示关机
|
||||
if (SRBleUtil.instance.isMacConnect(deviceMacId)) {
|
||||
rootView.visibility = View.INVISIBLE
|
||||
@@ -485,6 +495,16 @@ class MapViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun forTime(timestamp: Long): String {
|
||||
val durationMillis =
|
||||
if (timestamp < 1000000000000) System.currentTimeMillis() - timestamp * 1000
|
||||
else System.currentTimeMillis() - timestamp
|
||||
val hours = TimeUnit.MILLISECONDS.toHours(durationMillis)
|
||||
val minutes =
|
||||
TimeUnit.MILLISECONDS.toMinutes(durationMillis) - TimeUnit.HOURS.toMinutes(hours)
|
||||
val timeStr = if (hours > 0) "${hours}h ${minutes}m" else "${minutes}m"
|
||||
return timeStr
|
||||
}
|
||||
|
||||
fun setPetLocationReverseGeocode(
|
||||
context: Context,
|
||||
|
||||
BIN
app/src/main/res/drawable-xhdpi/gray_ico_switch_disable.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/gray_ico_switch_disable.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 830 B |
BIN
app/src/main/res/drawable-xhdpi/icon_device_sleep_image.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/icon_device_sleep_image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 354 B |
BIN
app/src/main/res/drawable-xxhdpi/gray_ico_switch_disable.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/gray_ico_switch_disable.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/icon_device_sleep_image.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/icon_device_sleep_image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 443 B |
BIN
app/src/main/res/drawable-xxxhdpi/gray_ico_switch_disable.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/gray_ico_switch_disable.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/icon_device_sleep_image.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/icon_device_sleep_image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 599 B |
@@ -3,6 +3,7 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/gray_ico_switch_on" android:state_checked="true" />
|
||||
<item android:drawable="@drawable/gray_ico_switch_disable" android:state_enabled="false" />
|
||||
<item android:drawable="@drawable/ico_switch_off" />
|
||||
|
||||
</selector>
|
||||
@@ -9,7 +9,7 @@
|
||||
</item>
|
||||
<item android:state_enabled="false">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/grey_color" />
|
||||
<solid android:color="@color/transparent" />
|
||||
<stroke android:width="@dimen/dp_1" android:color="@color/white_gray_color1" />
|
||||
<corners android:radius="@dimen/dp_44" />
|
||||
</shape>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
android:paddingHorizontal="@dimen/dp_14"
|
||||
android:paddingVertical="@dimen/dp_6"
|
||||
android:text="@string/acccount_btn_save"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/btn_color"
|
||||
android:textSize="@dimen/textSize12"
|
||||
app:qmui_radius="@dimen/dp_100"
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
style="@style/my_TextView_style_v2"
|
||||
android:layout_marginHorizontal="@dimen/dp_6"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:text="@string/txt_office"
|
||||
android:text="@string/txt_home"
|
||||
android:textSize="@dimen/textSize14"
|
||||
app:typeface="@string/roboto_bold_font" />
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shape32_grey_color_bg"
|
||||
android:paddingHorizontal="@dimen/dp_16"
|
||||
android:paddingVertical="@dimen/dp_4">
|
||||
android:paddingHorizontal="@dimen/dp_12"
|
||||
android:paddingVertical="@dimen/dp_2">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_led_btn_state"
|
||||
|
||||
@@ -1072,7 +1072,8 @@
|
||||
<string name="txt_pet_close">Pet is close, try Radar</string>
|
||||
<string name="txt_load_more_pull_text">Pull to load more</string>
|
||||
<string name="txt_load_more_release_text">Release to load</string>
|
||||
|
||||
<string name="txt_fully_charged">Fully charged</string>
|
||||
<string name="txt_fully_asleep">Fell asleep %s ago</string>
|
||||
<string name="txt_move_wake">Move %s to wake up</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user