1.删除断开连接蓝牙操作

2.修复宠物设备页切换另外一个宠物,正在连接蓝牙,电量不更新问题
3.关机、休眠、in wifi zone时,充电中,无网络70分钟时,开灯相关按键不可点击,呈灰色
4.增加关机状态在Power Off 开关处的显示:“ON” / "Off"
This commit is contained in:
yezhiqiu
2025-12-11 17:42:45 +08:00
parent 83007612f0
commit d87679408f
27 changed files with 366 additions and 165 deletions

View File

@@ -30,7 +30,7 @@ android {
targetSdkVersion 35 targetSdkVersion 35
versionCode 2101 versionCode 2101
// versionName "2.1.1" // versionName "2.1.1"
versionName "2.1.1-Beta7" versionName "2.1.1-Beta8"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -48,14 +48,22 @@ class HomePetTrackMenuAdapter(
background = background =
ContextCompat.getDrawable(context, R.drawable.selector_transparent_pressed) ContextCompat.getDrawable(context, R.drawable.selector_transparent_pressed)
} }
qMUICommonItemView.textView.typeface = mTypeface qMUICommonItemView.textView.apply {
typeface = mTypeface
val tColor = if (item.type == ConstantInt.SpecialType) R.color.grey_color
else R.color.qmui_config_color_gray_1
setTextColor(ContextCompat.getColor(context, tColor))
}
qMUICommonItemView.setOnClickListener { qMUICommonItemView.setOnClickListener {
when (position) { when (position) {
0 -> mHomeTrackFragment.goPetDataActivity(LedLightActivity::class.java) 0 -> mHomeTrackFragment.goPetDataActivity(LedLightActivity::class.java)
1 -> mHomeTrackFragment.goMapDeviceDataActivity(TrackingDurationSetActivity::class.java) 1 -> mHomeTrackFragment.goMapDeviceDataActivity(TrackingDurationSetActivity::class.java)
2 -> mHomeTrackFragment.goMapDeviceDataActivity(LiveDurationSetActivity::class.java) 2 -> mHomeTrackFragment.goMapDeviceDataActivity(LiveDurationSetActivity::class.java)
3 -> mHomeTrackFragment.firmwareCheckUpdate() 3 -> mHomeTrackFragment.firmwareCheckUpdate()
4 -> mHomeTrackFragment.goPetDataActivity(PowerOffActivity::class.java) 4 -> {
if (item.type == ConstantInt.SpecialType) return@setOnClickListener
mHomeTrackFragment.goPetDataActivity(PowerOffActivity::class.java)
}
} }
} }

View File

@@ -7,6 +7,7 @@ import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.tracker.R import com.abbidot.tracker.R
import com.abbidot.tracker.bean.MenuTxtBean import com.abbidot.tracker.bean.MenuTxtBean
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.MultipleEntity import com.abbidot.tracker.constant.MultipleEntity
import com.abbidot.tracker.widget.BatteryView import com.abbidot.tracker.widget.BatteryView
import com.abbidot.tracker.widget.MyBluetoothAnimView import com.abbidot.tracker.widget.MyBluetoothAnimView
@@ -28,9 +29,15 @@ class HomePetTrackStateAdapter(
holder.getTextView(R.id.tv_home_pet_device_state_name_item).apply { holder.getTextView(R.id.tv_home_pet_device_state_name_item).apply {
text = item.menuValue text = item.menuValue
setTextColor(ContextCompat.getColor(mContext, item.colorRedId)) val color = if (item.type == ConstantInt.SpecialType) R.color.grey_color
else item.colorRedId
setTextColor(ContextCompat.getColor(mContext, color))
} }
val color = if (item.type == ConstantInt.SpecialType) R.color.grey_color
else R.color.data_black_color
stateTextView.setTextColor(ContextCompat.getColor(mContext, color))
val bv = holder.getView(R.id.bv_home_pet_device_power) as BatteryView val bv = holder.getView(R.id.bv_home_pet_device_power) as BatteryView
val bluetoothAnimView = val bluetoothAnimView =
holder.getView(R.id.mba_home_pet_device_search_anim_item) as MyBluetoothAnimView holder.getView(R.id.mba_home_pet_device_search_anim_item) as MyBluetoothAnimView
@@ -53,7 +60,19 @@ class HomePetTrackStateAdapter(
else -> { else -> {
bv.visibility = View.GONE bv.visibility = View.GONE
bluetoothAnimView.visibility = View.GONE bluetoothAnimView.visibility = View.GONE
stateTextView.setCompoundDrawablesWithIntrinsicBounds(0, item.imageId, 0, 0) val drawable = ContextCompat.getDrawable(mContext, item.imageId)
if (null == drawable) {
stateTextView.setCompoundDrawablesWithIntrinsicBounds(0, item.imageId, 0, 0)
} else {
if (item.type == ConstantInt.SpecialType) {
drawable.setTint(ContextCompat.getColor(mContext, R.color.grey_color))
} else {
drawable.setTint(ContextCompat.getColor(mContext, R.color.data_black_color))
}
stateTextView.setCompoundDrawablesWithIntrinsicBounds(
null, drawable, null, null
)
}
} }
} }
} }

View File

@@ -1,12 +1,16 @@
package com.abbidot.tracker.adapter package com.abbidot.tracker.adapter
import android.content.Context import android.content.Context
import android.content.res.ColorStateList
import android.view.View import android.view.View
import androidx.core.content.ContextCompat
import com.abbidot.baselibrary.list.BaseRecyclerAdapter import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.tracker.R import com.abbidot.tracker.R
import com.abbidot.tracker.bean.WiFiZoneBean import com.abbidot.tracker.bean.WiFiZoneBean
import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.widget.TypefaceRoundButton
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButtonDrawable
/** /**
*/ */
@@ -16,15 +20,38 @@ class WiFiZoneAdapter(
private val isShowArrow = isShowArrowRight private val isShowArrow = isShowArrowRight
//禁用模式,无法点击的情况
private var isDisabledMode = true
override fun getEmptyLayoutId(viewType: Int) = R.layout.layout_virtual_fences_empty_view override fun getEmptyLayoutId(viewType: Int) = R.layout.layout_virtual_fences_empty_view
override fun getItemLayoutId(viewType: Int) = R.layout.item_wifi_zone_layout override fun getItemLayoutId(viewType: Int) = R.layout.item_wifi_zone_layout
override fun noData(holder: RecyclerViewHolder?) { override fun noData(holder: RecyclerViewHolder?) {
holder?.apply { holder?.apply {
getView(R.id.btn_empty_fences_add_safe_zone).visibility = getTextView(R.id.tv_fences_add_wifi_no_title).let {
if (isShowNoDataAddButton) View.VISIBLE val tColor = if (isDisabledMode) R.color.grey_color
else R.color.data_black_color
it.setTextColor(ContextCompat.getColor(mContext, tColor))
}
(getView(R.id.btn_empty_fences_add_safe_zone) as TypefaceRoundButton).let {
it.visibility = if (isShowNoDataAddButton) View.VISIBLE
else View.GONE else View.GONE
val tColor = if (isDisabledMode) R.color.grey_color
else R.color.select_color
it.setTextColor(ContextCompat.getColor(mContext, tColor))
(it.background as QMUIRoundButtonDrawable).let { d ->
val dColor = if (isDisabledMode) R.color.grey_color
else R.color.btn_color
d.setStrokeColors(
ColorStateList.valueOf(
ContextCompat.getColor(
mContext, dColor
)
)
)
}
}
} }
} }
@@ -40,4 +67,9 @@ class WiFiZoneAdapter(
if (isShowArrow) View.VISIBLE if (isShowArrow) View.VISIBLE
else View.GONE else View.GONE
} }
fun setDisabledMode(isDisabled: Boolean) {
isDisabledMode = isDisabled
notifyDataSetChanged()
}
} }

View File

@@ -32,6 +32,7 @@ import com.abbidot.baselibrary.util.LogUtil
import com.abbidot.tracker.R import com.abbidot.tracker.R
import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.GetResultCallback import com.abbidot.tracker.constant.GetResultCallback
import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.ViewUtil
import com.hjq.toast.Toaster import com.hjq.toast.Toaster
import com.qmuiteam.qmui.alpha.QMUIAlphaButton import com.qmuiteam.qmui.alpha.QMUIAlphaButton
@@ -91,6 +92,9 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
//是否需要适配底部EdgeToEdge //是否需要适配底部EdgeToEdge
var isEdgeToEdgeAdapterNavigationBars = true var isEdgeToEdgeAdapterNavigationBars = true
//防止按钮多次点击
private var mLimitExecutionTime = 0L
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
isFrontRunning = true isFrontRunning = true
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@@ -291,8 +295,19 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
} }
} }
/**
* 限制多次点击按钮
*/
fun isLimitClick(): Boolean {
//防止执行多次弹窗
if (Util.isTimeLimit(mLimitExecutionTime)) {
return true
}
mLimitExecutionTime = System.currentTimeMillis()
return false
}
override fun onClick(v: View?) { override fun onClick(v: View?) {
// 默认不实现,让子类实现
} }
/** /**
@@ -349,9 +364,11 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
/** /**
* 添加TopBar右边图片按钮 * 添加TopBar右边图片按钮
*/ */
fun addRightImageButton(@DrawableRes resId: Int): QMUIAlphaImageButton { fun addRightImageButton(
@DrawableRes resId: Int, setOnClick: Boolean = true
): QMUIAlphaImageButton {
val rightBtn = mTopBar!!.addRightImageButton(resId, R.id.topbar_right_change_button) val rightBtn = mTopBar!!.addRightImageButton(resId, R.id.topbar_right_change_button)
setOnClickListenerViews(rightBtn) if (setOnClick) setOnClickListenerViews(rightBtn)
return rightBtn return rightBtn
} }

View File

@@ -15,23 +15,24 @@ data class MenuTxtBean(
var colorRedId: Int, var colorRedId: Int,
var imageUrl: String, var imageUrl: String,
var isSwitch: Boolean, var isSwitch: Boolean,
var type: Int,
@MultipleEntity val menuType: Int @MultipleEntity val menuType: Int
) : MultiItemEntity { ) : MultiItemEntity {
//设置空的构造方法 //设置空的构造方法
constructor(@MultipleEntity menuType: Int) : this("", "", 0, 0, "", false, menuType) constructor(@MultipleEntity menuType: Int) : this("", "", 0, 0, "", false, 0, menuType)
//设置多个构造方法 //设置多个构造方法
constructor(menuName: String, menuValue: String, @MultipleEntity menuType: Int) : this( constructor(menuName: String, menuValue: String, @MultipleEntity menuType: Int) : this(
menuName, menuValue, 0, 0, "", false, menuType menuName, menuValue, 0, 0, "", false, 0, menuType
) )
constructor(menuName: String, menuValue: String) : this( constructor(menuName: String, menuValue: String) : this(
menuName, menuValue, 0, 0, "", false, MultipleEntity.TEXT menuName, menuValue, 0, 0, "", false, 0, MultipleEntity.TEXT
) )
constructor(menuName: String, imageId: Int, menuValue: String) : this( constructor(menuName: String, imageId: Int, menuValue: String) : this(
menuName, menuValue, imageId, 0, "", false, MultipleEntity.TEXT menuName, menuValue, imageId, 0, "", false, 0, MultipleEntity.TEXT
) )
@MultipleEntity @MultipleEntity

View File

@@ -6,5 +6,8 @@ package com.abbidot.tracker.bean
* @description: * @description:
*/ */
data class WiFiZoneListBean( data class WiFiZoneListBean(
var latitude: Double, var longitude: Double, var list: MutableList<WiFiZoneBean>? var latitude: Double,
var longitude: Double,
var list: MutableList<WiFiZoneBean>?,
var powerSwitch: Int
) )

View File

@@ -95,6 +95,9 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
var isRequestPetData = false var isRequestPetData = false
private var mCountdownType = ConstantInt.SpecialType private var mCountdownType = ConstantInt.SpecialType
//是否已经触发倒计时自动连接设备
private var isCountdownAutoConnBle = false
private val mFragments = mutableListOf<Fragment>( private val mFragments = mutableListOf<Fragment>(
ActivityV2Fragment.newInstance(this), ActivityV2Fragment.newInstance(this),
RouteV2Fragment.newInstance(this), RouteV2Fragment.newInstance(this),
@@ -135,6 +138,9 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
} }
}, 1) }, 1)
//解决异常 https://blog.csdn.net/w_lin/article/details/123872656
it.isSaveEnabled=false
edgeToEdgeAdapterBars(it) edgeToEdgeAdapterBars(it)
} }
@@ -187,31 +193,54 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
} }
} }
override fun liveDataObserve() { override fun onResume() {
super.onResume()
if (isCountdownAutoConnBle && mCountdownType == ConstantInt.Type1) {
LogUtil.e("onResume,自动连接设备20秒计时开始")
mCountDownTimerViewModel.startCountDown(20)
}
}
/* override fun onPause() {
super.onPause()
if (isCountdownAutoConnBle && mCountdownType == ConstantInt.Type1) {
LogUtil.e("onPause,自动连接设备倒计时停止")
mCountDownTimerViewModel.stopCountDown()
}
}
override fun liveDataObserve() {/*
Dispatchers.IO 在Android中主要用于执行输入输出操作如文件读写和网络请求 Dispatchers.IO 在Android中主要用于执行输入输出操作如文件读写和网络请求
Dispatchers.Main适用于处理与UI相关的操作如更新UI界面、响应用户输入等。 Dispatchers.Main适用于处理与UI相关的操作如更新UI界面、响应用户输入等。
Dispatchers.Default适用于执行CPU密集型任务如算法计算、数据处理等 Dispatchers.Default适用于执行CPU密集型任务如算法计算、数据处理等
Dispatchers.Unconfined不对协程的执行环境做任何限制协程将在调用它的线程中执行直到遇到挂起函数为止之后会在恢复执行时继续在之前的线程中执行 Dispatchers.Unconfined不对协程的执行环境做任何限制协程将在调用它的线程中执行直到遇到挂起函数为止之后会在恢复执行时继续在之前的线程中执行
*/ */
//出现闪退,5秒退出APP mCountDownTimerViewModel.apply {
mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) { mCountDowningLiveData.observe(this@HomeV2Activity) {
//自动重启APP if (mCountdownType == ConstantInt.Type1) {
isCountdownAutoConnBle = true
}
}
mCountDownEndLiveData.observe(this@HomeV2Activity) {
//自动重启APP
// val intent = baseContext.packageManager.getLaunchIntentForPackage(baseContext.packageName) // val intent = baseContext.packageManager.getLaunchIntentForPackage(baseContext.packageName)
// //与正常页面跳转一样可传递序列化数据,在Launch页面内获得 // //与正常页面跳转一样可传递序列化数据,在Launch页面内获得
// intent!!.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) // intent!!.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
// intent.putExtra("REBOOT", "reboot") // intent.putExtra("REBOOT", "reboot")
// startActivity(intent) // startActivity(intent)
if (mCountdownType == ConstantInt.Type0) {
finish() //出现闪退,5秒退出APP
System.gc() if (mCountdownType == ConstantInt.Type0) {
} else if (mCountdownType == ConstantInt.Type1) { finish()
LogUtil.e("自动连接蓝牙倒计时结束") System.gc()
if (SRBleUtil.instance.isBleEnable(mContext)) { } else if (mCountdownType == ConstantInt.Type1) {
autoConnectDevice() LogUtil.e("自动连接蓝牙倒计时结束")
mCountDownTimerViewModel.startCountDown(20) isCountdownAutoConnBle = false
if (SRBleUtil.instance.isBleEnable(mContext)) {
autoConnectDevice()
mCountDownTimerViewModel.startCountDown(20)
}
} }
} }
} }
@@ -678,6 +707,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
LogUtil.e("HomeV2Activity---------------onDestroy") LogUtil.e("HomeV2Activity---------------onDestroy")
mCountDownTimerViewModel.stopCountDown()
mSocketUtilManage?.destroy() mSocketUtilManage?.destroy()
mBleListenerReceiver?.let { mBleListenerReceiver?.let {
unregisterReceiver(it) unregisterReceiver(it)

View File

@@ -54,6 +54,9 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
//防止多次按返回键执行 //防止多次按返回键执行
private var isFinishSave = false private var isFinishSave = false
//禁用模式
private var isDisabledMode = true
override fun getTopBar() = mViewBinding.ilLedLightBar.titleTopBar override fun getTopBar() = mViewBinding.ilLedLightBar.titleTopBar
override fun initData() { override fun initData() {
@@ -96,7 +99,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
mViewBinding.ledLightMode.apply { mViewBinding.ledLightMode.apply {
ViewUtil.instance.showQMUICommonListItemView(mContext, this, { ViewUtil.instance.showQMUICommonListItemView(mContext, this, {
builder.build().show() if (!isDisabledMode) builder.build().show()
}, getString(R.string.txt_light_mode)) }, getString(R.string.txt_light_mode))
// mMapDeviceBean?.apply { // mMapDeviceBean?.apply {
// detailText = when { // detailText = when {
@@ -164,6 +167,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
) )
} }
setDisabledState(true)
mPetBean?.apply { mPetBean?.apply {
//查找是否连接了蓝牙 //查找是否连接了蓝牙
SRBleUtil.instance.getConnectMacDevice(macID)?.let { SRBleUtil.instance.getConnectMacDevice(macID)?.let {
@@ -197,13 +201,18 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
//接收开蓝牙操作,然后搜索连接设备 //接收开蓝牙操作,然后搜索连接设备
XEventBus.observe(this, EventName.ActionConDeviceState) { conState: Int -> XEventBus.observe(this, EventName.ActionConDeviceState) { conState: Int ->
mViewBinding.ledLightBluetoothTips.trbBleConnectState.let { view -> mViewBinding.ledLightBluetoothTips.trbBleConnectState.let { view ->
ViewUtil.instance.bleConActionState(this, view, conState) if (!isDisabledMode) {
ViewUtil.instance.bleConActionState(this, view, conState)
}
} }
} }
//接收蓝牙连接状态 //接收蓝牙连接状态
XEventBus.observe(this, EventName.ConnectDeviceState) { ble: BleTrackDeviceBean -> XEventBus.observe(this, EventName.ConnectDeviceState) { ble: BleTrackDeviceBean ->
mPetBean?.apply { mPetBean?.apply {
if (ble.mac == macID) { if (ble.mac == macID) {
mMapDeviceBean?.let {
updateDisabledState(it)
}
updateConState(ble) updateConState(ble)
} }
} }
@@ -212,13 +221,50 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
private fun setDeviceData(mapDeviceBean: MapDeviceBean) { private fun setDeviceData(mapDeviceBean: MapDeviceBean) {
mapDeviceBean.apply { mapDeviceBean.apply {
mViewBinding.ledLightOpenAndClose.switch.isChecked = ledSwitch == ConstantInt.Open mViewBinding.let {
it.ledLightOpenAndClose.switch.isChecked = ledSwitch == ConstantInt.Open
setLedLightColor( setLedLightColor(
Color.rgb(ledRedValue, ledGreenValue, ledBlueValue), true Color.rgb(ledRedValue, ledGreenValue, ledBlueValue), true
) )
if (ledMode == 0 || ledMode > mLedModeList.size) ledMode = 1 if (ledMode == 0 || ledMode > mLedModeList.size) ledMode = 1
mViewBinding.ledLightMode.detailText = mLedModeList[ledMode - 1] it.ledLightMode.detailText = mLedModeList[ledMode - 1]
updateDisabledState(this)
}
}
}
private fun updateDisabledState(mapDeviceBean: MapDeviceBean) {
mapDeviceBean.apply {
if (SRBleUtil.instance.isMacConnect(deviceMacId)) {
setDisabledState(false)
} else {
//是否超时上报
val isTimeoutReport = Util.isTimeoutReport(updateTime)
if (powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1 || isTimeoutReport) {
setDisabledState(true)
} else {
setDisabledState(false)
}
}
}
}
private fun setDisabledState(isDisabled: Boolean) {
isDisabledMode = isDisabled
mViewBinding.apply {
val tColor = if (isDisabled) {
btnLedLightSetSave.visibility = View.GONE
ledLightBluetoothTips.root.visibility = View.GONE
R.color.grey_color
} else {
btnLedLightSetSave.visibility = View.VISIBLE
ledLightBluetoothTips.root.visibility = View.VISIBLE
R.color.qmui_config_color_gray_1
}
ledLightOpenAndClose.textView.setTextColor(ContextCompat.getColor(mContext, tColor))
ledLightMode.textView.setTextColor(ContextCompat.getColor(mContext, tColor))
} }
} }
@@ -232,13 +278,12 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
view.text = getString(R.string.tracker_manage_set_ble_connect) view.text = getString(R.string.tracker_manage_set_ble_connect)
ContextCompat.getColor(mContext, R.color.cyan_color1) ContextCompat.getColor(mContext, R.color.cyan_color1)
} else { } else {
// showToast(R.string.txt_ble_connect_fail)
view.text = getString(R.string.tracker_manage_set_ble_unconnect) view.text = getString(R.string.tracker_manage_set_ble_unconnect)
ContextCompat.getColor(mContext, R.color.red_color4) ContextCompat.getColor(mContext, R.color.red_color4)
} }
view.setBackgroundColor(bgColor) view.setBackgroundColor(bgColor)
} }
if (isShowToast) { if (!isDisabledMode && isShowToast) {
ViewUtil.instance.bleConStateToast(this, trackBleDevice.conState, Gravity.CENTER) ViewUtil.instance.bleConStateToast(this, trackBleDevice.conState, Gravity.CENTER)
} }
} }
@@ -400,7 +445,12 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
btnLedLightIssue -> showLedIssue() btnLedLightIssue -> showLedIssue()
ilLedLightIssueLayout.tvCloseIssueBtn -> showLedIssue() ilLedLightIssueLayout.tvCloseIssueBtn -> showLedIssue()
ledLightOpenAndClose.switch -> setLedSwitch() ledLightOpenAndClose.switch -> {
if (isDisabledMode) {
ledLightOpenAndClose.switch.isChecked =
!ledLightOpenAndClose.switch.isChecked
} else setLedSwitch()
}
} }
} }
} }

View File

@@ -196,18 +196,11 @@ class AddWifiPowerZone1Activity :
if (btnString == getString(R.string.tracker_manage_set_ble_unconnect)) { if (btnString == getString(R.string.tracker_manage_set_ble_unconnect)) {
connectBle() connectBle()
} else if (btnString == getString(R.string.tracker_manage_set_ble_connect)) { } else if (btnString == getString(R.string.tracker_manage_set_ble_connect)) {
ViewUtil.instance.operateDialogTips(mContext, R.string.txt_disconnect_tips) { // ViewUtil.instance.operateDialogTips(mContext, R.string.txt_disconnect_tips) {
mPetBean?.apply { // mPetBean?.apply {
SRBleUtil.instance.disconnectToMac(macID) // SRBleUtil.instance.disconnectToMac(macID)
}
// if (isFirstBind) {
// BleManager.getInstance().disconnectAllDevice()
// } else {
// mPetBean?.apply {
// SRBleUtil.instance.disconnectToMac(macID)
// }
// } // }
} // }
} }
} }

View File

@@ -65,6 +65,9 @@ class EditWifiPowerZoneActivity :
private var isFirstBind = false private var isFirstBind = false
private var mBleTrackDeviceBean: BleTrackDeviceBean? = null private var mBleTrackDeviceBean: BleTrackDeviceBean? = null
//禁用模式,无法点击的情况
private var isDisabledMode = false
override fun getTopBar() = mViewBinding.editPowerZoneTopBar.titleTopBar override fun getTopBar() = mViewBinding.editPowerZoneTopBar.titleTopBar
override fun initData() { override fun initData() {
@@ -74,7 +77,14 @@ class EditWifiPowerZoneActivity :
initWifiData() initWifiData()
if (isEdit) mRightImageButton = addRightImageButton(R.drawable.icon_gray_delete_svg) if (isEdit) {
mRightImageButton = if (isDisabledMode) {
mViewBinding.ilEditPowerZoneBluetoothTips.root.visibility = View.GONE
addRightImageButton(R.drawable.icon_grey_delete, false)
} else {
addRightImageButton(R.drawable.icon_gray_delete_svg)
}
}
mEditZoneMapCommon = EditWifiZoneMapCommon() mEditZoneMapCommon = EditWifiZoneMapCommon()
mFragment = mEditZoneMapCommon.getMapFragment(mContext, mWiFiZoneBean) { mapLoadOk() } mFragment = mEditZoneMapCommon.getMapFragment(mContext, mWiFiZoneBean) { mapLoadOk() }
@@ -89,7 +99,6 @@ class EditWifiPowerZoneActivity :
btnSaveWifiZone, btnSaveWifiZone,
ivEditWifiZoneMapTypeBtn, ivEditWifiZoneMapTypeBtn,
btnCancelWifiZone, btnCancelWifiZone,
mRightImageButton,
ilEditPowerZoneBluetoothTips.trbBleConnectState ilEditPowerZoneBluetoothTips.trbBleConnectState
) )
@@ -208,6 +217,7 @@ class EditWifiPowerZoneActivity :
private fun initWifiData() { private fun initWifiData() {
intent.extras?.apply { intent.extras?.apply {
isFirstBind = getBoolean(ConstantString.isFirstBind, false) isFirstBind = getBoolean(ConstantString.isFirstBind, false)
isDisabledMode = getBoolean(ConstantString.isCheck, false)
//设备里的wifi数据,添加使用到 //设备里的wifi数据,添加使用到
mWiFiBean = mWiFiBean =
Util.getParcelableAdaptive(intent, ConstantString.WiFi, WiFiBean::class.java) Util.getParcelableAdaptive(intent, ConstantString.WiFi, WiFiBean::class.java)
@@ -237,6 +247,7 @@ class EditWifiPowerZoneActivity :
mWiFiZoneBean.deviceId = it.deviceId mWiFiZoneBean.deviceId = it.deviceId
//查找当前Mac的设备 //查找当前Mac的设备
mBleTrackDeviceBean = SRBleUtil.instance.getConnectMacDevice(it.macID) mBleTrackDeviceBean = SRBleUtil.instance.getConnectMacDevice(it.macID)
if (null != mBleTrackDeviceBean) isDisabledMode = false
} }
mPetCurrentLat = getDouble(ConstantString.Latitude, 0.0) mPetCurrentLat = getDouble(ConstantString.Latitude, 0.0)
@@ -325,6 +336,7 @@ class EditWifiPowerZoneActivity :
} }
private fun deleteWifiZone() { private fun deleteWifiZone() {
if (isDisabledMode) return
if (null == mBleTrackDeviceBean) { if (null == mBleTrackDeviceBean) {
showToast(R.string.tracker_manage_set_ble_unconnect, gravity = Gravity.CENTER) showToast(R.string.tracker_manage_set_ble_unconnect, gravity = Gravity.CENTER)
return return
@@ -348,7 +360,6 @@ class EditWifiPowerZoneActivity :
val data1 = SRBleCmdUtil.instance.byteToInt(data[1]) val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
val data2 = SRBleCmdUtil.instance.byteToInt(data[2]) val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
mRightImageButton?.isEnabled = true
if (data0 == 0x10 || data0 == 0x11) { if (data0 == 0x10 || data0 == 0x11) {
if (data1 == 0x01 && data2 == 0x00) { if (data1 == 0x01 && data2 == 0x00) {
//添加wifi 指令成功 //添加wifi 指令成功
@@ -365,9 +376,11 @@ class EditWifiPowerZoneActivity :
} }
} else if (data1 == 0x01 && data2 == 0x01) { } else if (data1 == 0x01 && data2 == 0x01) {
showLoading(false) showLoading(false)
mRightImageButton?.isEnabled = true
setButtonEnabled(mViewBinding.btnSaveWifiZone, ConstantInt.Type1) setButtonEnabled(mViewBinding.btnSaveWifiZone, ConstantInt.Type1)
showToast(R.string.txt_duplicate_wifi_not, gravity = Gravity.CENTER) showToast(R.string.txt_duplicate_wifi_not, gravity = Gravity.CENTER)
} else { } else {
mRightImageButton?.isEnabled = true
setButtonEnabled(mViewBinding.btnSaveWifiZone, ConstantInt.Type1) setButtonEnabled(mViewBinding.btnSaveWifiZone, ConstantInt.Type1)
showLoading(false) showLoading(false)
showToast("Fail", gravity = Gravity.CENTER) showToast("Fail", gravity = Gravity.CENTER)
@@ -423,18 +436,19 @@ class EditWifiPowerZoneActivity :
this@EditWifiPowerZoneActivity, macID this@EditWifiPowerZoneActivity, macID
) )
} else if (btnString == getString(R.string.tracker_manage_set_ble_connect)) { } else if (btnString == getString(R.string.tracker_manage_set_ble_connect)) {
ViewUtil.instance.operateDialogTips(mContext, R.string.txt_disconnect_tips) { // ViewUtil.instance.operateDialogTips(mContext, R.string.txt_disconnect_tips) {
if (isFirstBind) { // if (isFirstBind) {
BleManager.getInstance().disconnectAllDevice() // BleManager.getInstance().disconnectAllDevice()
} else { // } else {
SRBleUtil.instance.disconnectToMac(macID) // SRBleUtil.instance.disconnectToMac(macID)
} // }
} // }
} }
} }
} }
override fun onClick(v: View?) { override fun onClick(v: View?) {
if (isLimitClick()) return
mViewBinding.apply { mViewBinding.apply {
when (v!!) { when (v!!) {
ivEditWifiZoneRefreshBtn -> { ivEditWifiZoneRefreshBtn -> {

View File

@@ -1,8 +1,10 @@
package com.abbidot.tracker.ui.activity.device.wifi package com.abbidot.tracker.ui.activity.device.wifi
import android.content.Intent import android.content.Intent
import android.content.res.ColorStateList
import android.view.View import android.view.View
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import com.abbidot.baselibrary.constant.EventName import com.abbidot.baselibrary.constant.EventName
import com.abbidot.baselibrary.constant.MMKVKey import com.abbidot.baselibrary.constant.MMKVKey
import com.abbidot.baselibrary.eventbus.XEventBus import com.abbidot.baselibrary.eventbus.XEventBus
@@ -21,6 +23,7 @@ import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.vm.WiFiZoneViewModel import com.abbidot.tracker.vm.WiFiZoneViewModel
import com.qmuiteam.qmui.util.QMUIDisplayHelper import com.qmuiteam.qmui.util.QMUIDisplayHelper
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButtonDrawable
class PowerSavingSetActivity : class PowerSavingSetActivity :
BaseActivity<ActivityPowerSavingSetBinding>(ActivityPowerSavingSetBinding::inflate) { BaseActivity<ActivityPowerSavingSetBinding>(ActivityPowerSavingSetBinding::inflate) {
@@ -33,6 +36,9 @@ class PowerSavingSetActivity :
private var mPetCurrentLat = 0.0 private var mPetCurrentLat = 0.0
private var mPetCurrentLon = 0.0 private var mPetCurrentLon = 0.0
//禁用模式,无法点击的情况
private var isDisabledMode = true
override fun getTopBar() = mViewBinding.ilPowerSavingSetTopBar.titleTopBar override fun getTopBar() = mViewBinding.ilPowerSavingSetTopBar.titleTopBar
override fun initData() { override fun initData() {
@@ -53,6 +59,7 @@ class PowerSavingSetActivity :
goEditWiFiZone(pos) goEditWiFiZone(pos)
} }
}) })
setDisabledMode(false)
} }
mViewBinding.apply { mViewBinding.apply {
@@ -88,6 +95,7 @@ class PowerSavingSetActivity :
mZoneAdapter.setData(null) mZoneAdapter.setData(null)
mPetCurrentLat = latitude mPetCurrentLat = latitude
mPetCurrentLon = longitude mPetCurrentLon = longitude
isDisabledMode = powerSwitch == ConstantInt.Type0
list?.let { wifi -> list?.let { wifi ->
setWifiListData(wifi) setWifiListData(wifi)
} }
@@ -118,12 +126,21 @@ class PowerSavingSetActivity :
intent.putExtra(ConstantString.Pet, mPetBean) intent.putExtra(ConstantString.Pet, mPetBean)
intent.putExtra(ConstantString.Latitude, mPetCurrentLat) intent.putExtra(ConstantString.Latitude, mPetCurrentLat)
intent.putExtra(ConstantString.Longitude, mPetCurrentLon) intent.putExtra(ConstantString.Longitude, mPetCurrentLon)
intent.putExtra(ConstantString.isCheck, isDisabledMode)
startActivity(intent) startActivity(intent)
} }
}) })
} }
private fun setWifiListData(list: MutableList<WiFiZoneBean>) { private fun setWifiListData(list: MutableList<WiFiZoneBean>) {
if (list.size > 0) {
val aDrawable = mViewBinding.btnPowerSavingSetAdd.background as QMUIRoundButtonDrawable
val dColor = if (isDisabledMode) R.color.grey_color
else R.color.btn_color
val tColor = ContextCompat.getColor(mContext, dColor)
aDrawable.setStrokeColors(ColorStateList.valueOf(tColor))
mViewBinding.btnPowerSavingSetAdd.setTextColor(tColor)
}
list.apply { list.apply {
mViewBinding.let { mViewBinding.let {
if (size > 0) { if (size > 0) {
@@ -157,7 +174,10 @@ class PowerSavingSetActivity :
override fun onClick(v: View?) { override fun onClick(v: View?) {
mViewBinding.apply { mViewBinding.apply {
when (v!!) { when (v!!) {
btnPowerSavingSetAdd -> goAddWifiZone() btnPowerSavingSetAdd -> {
if (isDisabledMode) return
goAddWifiZone()
}
} }
} }
} }

View File

@@ -122,7 +122,12 @@ class HomeTrackFragment :
} }
4 -> connectionBtn(getData()[pos].menuValue) 4 -> connectionBtn(getData()[pos].menuValue)
5 -> setLedSwitch() 5 -> {
if (mHomePetTrackStateAdapter.getData()[pos].type == ConstantInt.SpecialType) {
return
}
setLedSwitch()
}
} }
} }
}) })
@@ -175,7 +180,11 @@ class HomeTrackFragment :
override fun onAgainListener() { override fun onAgainListener() {
val share = MMKVUtil.getInt(MMKVKey.Shared) val share = MMKVUtil.getInt(MMKVKey.Shared)
if (share == ConstantInt.NoShare) { if (share == ConstantInt.NoShare) {
goPetDataActivity(PowerSavingSetActivity::class.java) mMapDeviceBean?.let {
if (it.powerSwitch != ConstantInt.Type0) {
goPetDataActivity(PowerSavingSetActivity::class.java)
}
}
} }
} }
}) })
@@ -361,11 +370,12 @@ class HomeTrackFragment :
fun getPetTrackerInfoData() { fun getPetTrackerInfoData() {
getHomeV2Activity()?.let { getHomeV2Activity()?.let {
it.getPet()?.apply { it.getPet()?.apply {
// mViewBinding.ivHomePetTrackPetHead.load(imgurl)
mTrackerInfoViewModel.getPetTrackerInfo(it, deviceId)
mTrackMenuList[1].menuValue = "" mTrackMenuList[1].menuValue = ""
mTrackMenuList[2].menuValue = "" mTrackMenuList[2].menuValue = ""
mTrackMenuList[4].menuValue = ""
mTrackerInfoViewModel.getPetTrackerInfo(it, deviceId)
getBleTrackDeviceBean(false)?.let { ble -> getBleTrackDeviceBean(false)?.let { ble ->
if (BleManager.getInstance().isConnected(macID)) { if (BleManager.getInstance().isConnected(macID)) {
@@ -395,7 +405,7 @@ class HomeTrackFragment :
mTrackMenuList[3].menuValue = "" mTrackMenuList[3].menuValue = ""
mTrackMenuList[3].isSwitch = false mTrackMenuList[3].isSwitch = false
} }
mTrackMenuAdapter.notifyItemRangeChanged(1, 3) mTrackMenuAdapter.notifyItemRangeChanged(1, 4)
} }
} }
} }
@@ -455,7 +465,8 @@ class HomeTrackFragment :
mTrackStateList, mTrackStateList,
getString(R.string.txt_light), getString(R.string.txt_light),
getString(R.string.tracker_manage_set_led_off), getString(R.string.tracker_manage_set_led_off),
imageResId = R.drawable.icon_light_svg imageResId = R.drawable.icon_light_svg,
type = ConstantInt.SpecialType
) )
mTrackMenuList = mutableListOf() mTrackMenuList = mutableListOf()
@@ -470,9 +481,8 @@ class HomeTrackFragment :
menuType = MultipleEntity.IMG_TEXT_IMG menuType = MultipleEntity.IMG_TEXT_IMG
) )
ViewUtil.instance.addMenuBean( ViewUtil.instance.addMenuBean(
mTrackMenuList, mTrackMenuList, getString(R.string.txt_power_off)
getString(R.string.txt_power_off), // menuType = MultipleEntity.IMG_TEXT//, menuType = MultipleEntity.TEXT_NAME
menuType = MultipleEntity.IMG_TEXT//, menuType = MultipleEntity.TEXT_NAME
) )
} }
@@ -564,17 +574,54 @@ class HomeTrackFragment :
} }
} }
mTrackStateList[4].let { mTrackStateList[4].let {
if (it.menuValue == getString(R.string.txt_connecting)) return if (it.menuValue != getString(R.string.txt_connecting)) {
it.colorRedId = R.color.orange_color3 it.colorRedId = R.color.orange_color3
it.menuValue = if (BleManager.getInstance().isConnected(deviceMacId)) { it.menuValue = if (BleManager.getInstance().isConnected(deviceMacId)) {
it.colorRedId = R.color.blue_color1 it.colorRedId = R.color.blue_color1
getString(R.string.txt_connected) getString(R.string.txt_connected)
} else { } else {
getString(R.string.txt_unconnect_no) getString(R.string.txt_unconnect_no)
}
} }
} }
setLedControlState(mapDeviceBean)
mTrackMenuList.let {
it[1].menuValue =
(gnssInterval / 60).toString() + getString(R.string.data_active_unit_min)
it[2].menuValue =
(liveTime / 60).toString() + getString(R.string.data_active_unit_min)
it[4].type = if (powerSwitch == ConstantInt.Type3) ConstantInt.SpecialType
else ConstantInt.Type0
it[4].menuValue = when (powerSwitch) {
ConstantInt.Type0 -> getString(R.string.tracker_manage_set_led_off)
ConstantInt.Type1 -> getString(R.string.tracker_manage_set_led_on)
else -> ""
}
}
if (powerSwitch == ConstantInt.Type0) {
mZoneAdapter.setDisabledMode(true)
} else {
mZoneAdapter.setDisabledMode(false)
}
}
mTrackMenuAdapter.notifyItemRangeChanged(1, mTrackMenuList.size)
mHomePetTrackStateAdapter.notifyItemRangeChanged(0, mTrackStateList.size)
}
private fun setLedControlState(mapDeviceBean: MapDeviceBean) {
mapDeviceBean.apply {
//是否超时上报
val isTimeoutReport = Util.isTimeoutReport(updateTime)
mTrackStateList[5].let { mTrackStateList[5].let {
it.colorRedId = R.color.orange_color3 it.colorRedId = R.color.orange_color3
it.type = if (SRBleUtil.instance.isMacConnect(deviceMacId)) {
ConstantInt.Type0
} else if (powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1 || isTimeoutReport) {
ConstantInt.SpecialType
} else ConstantInt.Type0
it.menuValue = if (ledSwitch == ConstantInt.Open) { it.menuValue = if (ledSwitch == ConstantInt.Open) {
it.colorRedId = R.color.blue_color1 it.colorRedId = R.color.blue_color1
getString(R.string.tracker_manage_set_led_on) getString(R.string.tracker_manage_set_led_on)
@@ -582,18 +629,7 @@ class HomeTrackFragment :
getString(R.string.tracker_manage_set_led_off) getString(R.string.tracker_manage_set_led_off)
} }
} }
mTrackMenuList.let {
it[1].menuValue =
(gnssInterval / 60).toString() + getString(R.string.data_active_unit_min)
it[2].menuValue =
(liveTime / 60).toString() + getString(R.string.data_active_unit_min)
it[4].menuValue = powerSwitch.toString()
}
} }
mTrackMenuAdapter.notifyItemRangeChanged(1, mTrackMenuList.size)
mHomePetTrackStateAdapter.notifyItemRangeChanged(0, mTrackStateList.size)
} }
private fun setZoneData(mapDeviceBean: MapDeviceBean) { private fun setZoneData(mapDeviceBean: MapDeviceBean) {
@@ -681,7 +717,10 @@ class HomeTrackFragment :
*/ */
private fun updateConState(trackBleDevice: BleTrackDeviceBean) { private fun updateConState(trackBleDevice: BleTrackDeviceBean) {
mBleTrackDeviceBean = trackBleDevice mBleTrackDeviceBean = trackBleDevice
mMapDeviceBean?.apply {
setLedControlState(this)
mHomePetTrackStateAdapter.notifyItemChanged(5)
}
if (trackBleDevice.conState == ConState.CONNECTED) { if (trackBleDevice.conState == ConState.CONNECTED) {
if (isDFUCallback) { if (isDFUCallback) {
showToast(R.string.txt_upgrade_success) showToast(R.string.txt_upgrade_success)
@@ -842,7 +881,7 @@ class HomeTrackFragment :
} }
}) })
} else if (btnString == getString(R.string.txt_connected)) { } else if (btnString == getString(R.string.txt_connected)) {
operateDeviceTips(R.string.txt_disconnect_tips, 1) // operateDeviceTips(R.string.txt_disconnect_tips, 1)
} }
} }

View File

@@ -466,7 +466,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
//隐藏蓝牙nearby //隐藏蓝牙nearby
mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE
mViewBinding.ilHomeMapPetLocation.root.visibility = View.GONE mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE
ViewUtil.instance.selectPetDialogShow( ViewUtil.instance.selectPetDialogShow(
mContext, mContext,

View File

@@ -130,8 +130,8 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
mContext!!.resources, R.drawable.icon_location_svg mContext!!.resources, R.drawable.icon_location_svg
) )
mPetIconDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap!!) mPetIconDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap!!)
mMarker?.setIcon(mPetIconDescriptor)
} }
mMarker?.setIcon(mPetIconDescriptor)
} }
/** /**

View File

@@ -270,6 +270,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
// addPolyline(mGoogleMap!!, latLng) // addPolyline(mGoogleMap!!, latLng)
// addUserAndPetLine(latLng) // addUserAndPetLine(latLng)
refreshPetCurrentLocation(latLng, needMoveCamera = isMoveCamera) refreshPetCurrentLocation(latLng, needMoveCamera = isMoveCamera)
isMoveCamera = false
// mRippleCircle?.apply { // mRippleCircle?.apply {
// //一像素对应几米 // //一像素对应几米
@@ -293,6 +294,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
if (i == trackList.size - 1) { if (i == trackList.size - 1) {
// addUserAndPetLine(latLng) // addUserAndPetLine(latLng)
refreshPetCurrentLocation(latLng, needMoveCamera = isMoveCamera) refreshPetCurrentLocation(latLng, needMoveCamera = isMoveCamera)
isMoveCamera = false
} }
} }
} }

View File

@@ -70,7 +70,6 @@ import com.abbidot.tracker.constant.MultipleEntity
import com.abbidot.tracker.dialog.MyAlertDialog import com.abbidot.tracker.dialog.MyAlertDialog
import com.abbidot.tracker.dialog.SelectMapTypeDialog import com.abbidot.tracker.dialog.SelectMapTypeDialog
import com.abbidot.tracker.ui.activity.WebViewActivity import com.abbidot.tracker.ui.activity.WebViewActivity
import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.widget.TypefaceTextView import com.abbidot.tracker.widget.TypefaceTextView
import com.daimajia.androidanimations.library.Techniques import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo import com.daimajia.androidanimations.library.YoYo
@@ -785,6 +784,7 @@ class ViewUtil private constructor() {
imageUrl: String = "", imageUrl: String = "",
colorRedId: Int = R.color.orange_color3, colorRedId: Int = R.color.orange_color3,
isSwitch: Boolean = false, isSwitch: Boolean = false,
type: Int = ConstantInt.Type0,
@MultipleEntity menuType: Int = MultipleEntity.TEXT @MultipleEntity menuType: Int = MultipleEntity.TEXT
) { ) {
val menuTxtBean = MenuTxtBean(name, value, menuType) val menuTxtBean = MenuTxtBean(name, value, menuType)
@@ -795,9 +795,10 @@ class ViewUtil private constructor() {
menuTxtBean.imageUrl = imageUrl menuTxtBean.imageUrl = imageUrl
} }
if (isSwitch) { if (isSwitch) {
menuTxtBean.isSwitch = isSwitch menuTxtBean.isSwitch = true
} }
menuTxtBean.colorRedId = colorRedId menuTxtBean.colorRedId = colorRedId
menuTxtBean.type = type
list.add(menuTxtBean) list.add(menuTxtBean)
} }
@@ -1079,7 +1080,7 @@ class ViewUtil private constructor() {
else -> { else -> {
textView.text = baseActivity.getString(R.string.tracker_manage_set_ble_unconnect) textView.text = baseActivity.getString(R.string.tracker_manage_set_ble_unconnect)
baseActivity.showToast(R.string.txt_ble_connect_fail, gravity = gravity) // baseActivity.showToast(R.string.txt_ble_connect_fail, gravity = gravity)
} }
} }
textView.setBackgroundColor(ContextCompat.getColor(baseActivity, R.color.red_color4)) textView.setBackgroundColor(ContextCompat.getColor(baseActivity, R.color.red_color4))
@@ -1097,7 +1098,7 @@ class ViewUtil private constructor() {
R.string.txt_unconnect_no, gravity = gravity R.string.txt_unconnect_no, gravity = gravity
) )
else -> baseActivity.showToast(R.string.txt_connect_fail, gravity = gravity) // else -> baseActivity.showToast(R.string.txt_connect_fail, gravity = gravity)
} }
} }
@@ -1110,9 +1111,9 @@ class ViewUtil private constructor() {
if (btnString == context.getString(R.string.tracker_manage_set_ble_unconnect)) { if (btnString == context.getString(R.string.tracker_manage_set_ble_unconnect)) {
noConnectCallback() noConnectCallback()
} else if (btnString == context.getString(R.string.tracker_manage_set_ble_connect)) { } else if (btnString == context.getString(R.string.tracker_manage_set_ble_connect)) {
operateDialogTips(context, R.string.txt_disconnect_tips) { // operateDialogTips(context, R.string.txt_disconnect_tips) {
SRBleUtil.instance.disconnectToMac(mac) // SRBleUtil.instance.disconnectToMac(mac)
} // }
} }
} }

View File

@@ -182,6 +182,10 @@ class SRBleUtil private constructor() {
}) })
} }
fun isMacConnect(mac: String): Boolean {
return BleManager.getInstance().isConnected(mac)
}
/** /**
* 打开通道通知 * 打开通道通知
*/ */
@@ -240,19 +244,19 @@ class SRBleUtil private constructor() {
BleManager.getInstance() BleManager.getInstance()
.notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() { .notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() {
override fun onNotifySuccess() { override fun onNotifySuccess() {
LogUtil.e("打开蓝牙日志上报通道成功:${bleDevice.name}--${bleDevice.mac}") LogUtil.e("打开蓝牙上报通道成功:${bleDevice.name}--${bleDevice.mac}")
openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID) openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID)
} }
override fun onNotifyFailure(exception: BleException?) { override fun onNotifyFailure(exception: BleException?) {
LogUtil.e("打开蓝牙日志上报通道失败:${bleDevice.mac}$exception") LogUtil.e("打开蓝牙上报通道失败:${bleDevice.mac}$exception")
openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID) openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID)
} }
override fun onCharacteristicChanged(data: ByteArray?) { override fun onCharacteristicChanged(data: ByteArray?) {
data?.apply { data?.apply {
val formatData = HexUtil.formatHexString(data, true) val formatData = HexUtil.formatHexString(data, true)
LogUtil.e("接收蓝牙日志上报通道数据:${bleDevice.mac}$formatData") LogUtil.e("接收蓝牙上报通道数据:${bleDevice.mac}$formatData")
val deviceData = ReceiveDeviceData(bleDevice, data, bleDevice.mac) val deviceData = ReceiveDeviceData(bleDevice, data, bleDevice.mac)
XEventBus.post(EventName.BleReport, deviceData) XEventBus.post(EventName.BleReport, deviceData)
} }

View File

@@ -338,19 +338,21 @@ class MapViewModel : ViewModel() {
context.getString(R.string.txt_outside) context.getString(R.string.txt_outside)
} }
} }
if (it.powerSwitch == ConstantInt.Type0) menuType = ConstantInt.Close
value = context.getString(R.string.txt_smart_power_zone) + "$wifiZoneValue" value = context.getString(R.string.txt_smart_power_zone) + "$wifiZoneValue"
} }
deviceStateList[3].apply { deviceStateList[3].apply {
if (isTimeoutReport || it.lteSignal == ConstantInt.NoSignal || it.powerSwitch == ConstantInt.Type0 || it.powerSwitch == ConstantInt.Type2) { menuType =
menuType = ConstantInt.Close if (isTimeoutReport || it.lteSignal == ConstantInt.NoSignal || it.powerSwitch == ConstantInt.Type0 || it.powerSwitch == ConstantInt.Type2) {
// state = -1 ConstantInt.Close
// value = // state = -1
// String.format(context.getString(R.string.tracker_manage_set_battery), "--") // value =
// name = "N/A" // String.format(context.getString(R.string.tracker_manage_set_battery), "--")
} else { // name = "N/A"
menuType = if (it.batteryLevel > ConstantInt.LowBattery20) ConstantInt.Open } else {
else ConstantInt.Close if (it.batteryLevel > ConstantInt.LowBattery20) ConstantInt.Open
} else ConstantInt.Close
}
state = Utils.calculatePowerLevel(it.batteryLevel) state = Utils.calculatePowerLevel(it.batteryLevel)
value = String.format( value = String.format(
context.getString(R.string.tracker_manage_set_battery), "${it.batteryLevel}" context.getString(R.string.tracker_manage_set_battery), "${it.batteryLevel}"

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,42 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeWidth="1"
android:pathData="M5,10V19"
android:fillColor="#00000000"
android:strokeColor="#0F1719"
android:strokeLineCap="round"/>
<path
android:strokeWidth="1"
android:pathData="M5.808,9.281C5.435,9.76 5.249,10 5,10C4.751,10 4.565,9.76 4.192,9.281L3.446,8.323C2.373,6.945 1.836,6.255 2.044,5.688C2.066,5.63 2.092,5.575 2.122,5.521C2.423,5 3.282,5 5,5C6.718,5 7.577,5 7.878,5.521C7.908,5.575 7.934,5.63 7.956,5.688C8.164,6.255 7.627,6.945 6.554,8.323L5.808,9.281Z"
android:fillColor="#00000000"
android:strokeColor="#0F1719"
android:strokeLineCap="round"/>
<path
android:strokeWidth="1"
android:pathData="M9,14V19"
android:fillColor="#00000000"
android:strokeColor="#0F1719"
android:strokeLineCap="round"/>
<path
android:strokeWidth="1"
android:pathData="M13,11V19"
android:fillColor="#00000000"
android:strokeColor="#0F1719"
android:strokeLineCap="round"/>
<path
android:strokeWidth="1"
android:pathData="M17,10V19"
android:fillColor="#00000000"
android:strokeColor="#0F1719"
android:strokeLineCap="round"/>
<path
android:strokeWidth="1"
android:pathData="M21,7V19"
android:fillColor="#00000000"
android:strokeColor="#0F1719"
android:strokeLineCap="round"/>
</vector>

View File

@@ -24,7 +24,7 @@
<com.abbidot.tracker.widget.TypefaceTextView <com.abbidot.tracker.widget.TypefaceTextView
android:id="@+id/tv_home_pet_device_state_item" android:id="@+id/tv_home_pet_device_state_item"
style="@style/my_TextView_style_v2" style="@style/my_TextView_style_v2"
android:drawableTop="@drawable/icon_map_signal_svg" android:drawableTop="@drawable/icon_map_signal"
android:drawablePadding="@dimen/dp_6" android:drawablePadding="@dimen/dp_6"
android:text="@string/tracker_manage_set_network" android:text="@string/tracker_manage_set_network"
android:textSize="@dimen/textSize12" android:textSize="@dimen/textSize12"

View File

@@ -9,6 +9,7 @@
android:paddingVertical="@dimen/dp_60"> android:paddingVertical="@dimen/dp_60">
<com.abbidot.tracker.widget.TypefaceTextView <com.abbidot.tracker.widget.TypefaceTextView
android:id="@+id/tv_fences_add_wifi_no_title"
style="@style/my_TextView_style_v2" style="@style/my_TextView_style_v2"
android:text="@string/txt_no_zone_data" android:text="@string/txt_no_zone_data"
android:textSize="@dimen/textSize24" android:textSize="@dimen/textSize24"

View File

@@ -371,4 +371,5 @@
<color name="permission_no_check_color">#EEEFEF</color> <color name="permission_no_check_color">#EEEFEF</color>
<color name="grey_color_64">#64000000</color> <color name="grey_color_64">#64000000</color>
<color name="grey_color_90">#F9FFE3</color> <color name="grey_color_90">#F9FFE3</color>
<color name="grey_color">#A6A6A6</color>
</resources> </resources>

View File

@@ -20,14 +20,18 @@ object XEventBus {
} }
fun <T> post(@EventName eventName: String, message: T) { fun <T> post(@EventName eventName: String, message: T) {
val eventLiveData = with<T>(eventName) message?.let {
eventLiveData.postValue(message!!) val eventLiveData = with<T>(eventName)
eventLiveData.postValue(it)
}
} }
fun <T> observe(owner: LifecycleOwner, fun <T> observe(
@EventName eventName: String, owner: LifecycleOwner,
sticky: Boolean = false, @EventName eventName: String,
observer: Observer<T>) { sticky: Boolean = false,
observer: Observer<T>
) {
with<T>(eventName).observe(owner, sticky, observer) with<T>(eventName).observe(owner, sticky, observer)
} }
@@ -39,10 +43,12 @@ object XEventBus {
/** /**
* 空Message调用 * 空Message调用
*/ */
fun observe(owner: LifecycleOwner, fun observe(
@EventName eventName: String, owner: LifecycleOwner,
sticky: Boolean = false, @EventName eventName: String,
observer: () -> Unit) { sticky: Boolean = false,
observer: () -> Unit
) {
with<EmptyMessage>(eventName).observe(owner, sticky) { with<EmptyMessage>(eventName).observe(owner, sticky) {
observer() observer()
} }