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
versionCode 2101
// versionName "2.1.1"
versionName "2.1.1-Beta7"
versionName "2.1.1-Beta8"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -48,14 +48,22 @@ class HomePetTrackMenuAdapter(
background =
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 {
when (position) {
0 -> mHomeTrackFragment.goPetDataActivity(LedLightActivity::class.java)
1 -> mHomeTrackFragment.goMapDeviceDataActivity(TrackingDurationSetActivity::class.java)
2 -> mHomeTrackFragment.goMapDeviceDataActivity(LiveDurationSetActivity::class.java)
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.tracker.R
import com.abbidot.tracker.bean.MenuTxtBean
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.MultipleEntity
import com.abbidot.tracker.widget.BatteryView
import com.abbidot.tracker.widget.MyBluetoothAnimView
@@ -28,9 +29,15 @@ class HomePetTrackStateAdapter(
holder.getTextView(R.id.tv_home_pet_device_state_name_item).apply {
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 bluetoothAnimView =
holder.getView(R.id.mba_home_pet_device_search_anim_item) as MyBluetoothAnimView
@@ -53,7 +60,19 @@ class HomePetTrackStateAdapter(
else -> {
bv.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
import android.content.Context
import android.content.res.ColorStateList
import android.view.View
import androidx.core.content.ContextCompat
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.tracker.R
import com.abbidot.tracker.bean.WiFiZoneBean
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 var isDisabledMode = true
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 noData(holder: RecyclerViewHolder?) {
holder?.apply {
getView(R.id.btn_empty_fences_add_safe_zone).visibility =
if (isShowNoDataAddButton) View.VISIBLE
getTextView(R.id.tv_fences_add_wifi_no_title).let {
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
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
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.constant.ConstantInt
import com.abbidot.tracker.constant.GetResultCallback
import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil
import com.hjq.toast.Toaster
import com.qmuiteam.qmui.alpha.QMUIAlphaButton
@@ -91,6 +92,9 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
//是否需要适配底部EdgeToEdge
var isEdgeToEdgeAdapterNavigationBars = true
//防止按钮多次点击
private var mLimitExecutionTime = 0L
override fun onCreate(savedInstanceState: Bundle?) {
isFrontRunning = true
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?) {
// 默认不实现,让子类实现
}
/**
@@ -349,9 +364,11 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
/**
* 添加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)
setOnClickListenerViews(rightBtn)
if (setOnClick) setOnClickListenerViews(rightBtn)
return rightBtn
}

View File

@@ -15,23 +15,24 @@ data class MenuTxtBean(
var colorRedId: Int,
var imageUrl: String,
var isSwitch: Boolean,
var type: Int,
@MultipleEntity val menuType: Int
) : 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(
menuName, menuValue, 0, 0, "", false, menuType
menuName, menuValue, 0, 0, "", false, 0, menuType
)
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(
menuName, menuValue, imageId, 0, "", false, MultipleEntity.TEXT
menuName, menuValue, imageId, 0, "", false, 0, MultipleEntity.TEXT
)
@MultipleEntity

View File

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

View File

@@ -54,6 +54,9 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
//防止多次按返回键执行
private var isFinishSave = false
//禁用模式
private var isDisabledMode = true
override fun getTopBar() = mViewBinding.ilLedLightBar.titleTopBar
override fun initData() {
@@ -96,7 +99,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
mViewBinding.ledLightMode.apply {
ViewUtil.instance.showQMUICommonListItemView(mContext, this, {
builder.build().show()
if (!isDisabledMode) builder.build().show()
}, getString(R.string.txt_light_mode))
// mMapDeviceBean?.apply {
// detailText = when {
@@ -164,6 +167,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
)
}
setDisabledState(true)
mPetBean?.apply {
//查找是否连接了蓝牙
SRBleUtil.instance.getConnectMacDevice(macID)?.let {
@@ -197,13 +201,18 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
//接收开蓝牙操作,然后搜索连接设备
XEventBus.observe(this, EventName.ActionConDeviceState) { conState: Int ->
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 ->
mPetBean?.apply {
if (ble.mac == macID) {
mMapDeviceBean?.let {
updateDisabledState(it)
}
updateConState(ble)
}
}
@@ -212,13 +221,50 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
private fun setDeviceData(mapDeviceBean: MapDeviceBean) {
mapDeviceBean.apply {
mViewBinding.ledLightOpenAndClose.switch.isChecked = ledSwitch == ConstantInt.Open
mViewBinding.let {
it.ledLightOpenAndClose.switch.isChecked = ledSwitch == ConstantInt.Open
setLedLightColor(
Color.rgb(ledRedValue, ledGreenValue, ledBlueValue), true
)
if (ledMode == 0 || ledMode > mLedModeList.size) ledMode = 1
mViewBinding.ledLightMode.detailText = mLedModeList[ledMode - 1]
setLedLightColor(
Color.rgb(ledRedValue, ledGreenValue, ledBlueValue), true
)
if (ledMode == 0 || ledMode > mLedModeList.size) 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)
ContextCompat.getColor(mContext, R.color.cyan_color1)
} else {
// showToast(R.string.txt_ble_connect_fail)
view.text = getString(R.string.tracker_manage_set_ble_unconnect)
ContextCompat.getColor(mContext, R.color.red_color4)
}
view.setBackgroundColor(bgColor)
}
if (isShowToast) {
if (!isDisabledMode && isShowToast) {
ViewUtil.instance.bleConStateToast(this, trackBleDevice.conState, Gravity.CENTER)
}
}
@@ -400,7 +445,12 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
btnLedLightIssue -> 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)) {
connectBle()
} else if (btnString == getString(R.string.tracker_manage_set_ble_connect)) {
ViewUtil.instance.operateDialogTips(mContext, R.string.txt_disconnect_tips) {
mPetBean?.apply {
SRBleUtil.instance.disconnectToMac(macID)
}
// if (isFirstBind) {
// BleManager.getInstance().disconnectAllDevice()
// } else {
// mPetBean?.apply {
// SRBleUtil.instance.disconnectToMac(macID)
// }
// ViewUtil.instance.operateDialogTips(mContext, R.string.txt_disconnect_tips) {
// mPetBean?.apply {
// SRBleUtil.instance.disconnectToMac(macID)
// }
}
// }
}
}

View File

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

View File

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

View File

@@ -122,7 +122,12 @@ class HomeTrackFragment :
}
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() {
val share = MMKVUtil.getInt(MMKVKey.Shared)
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() {
getHomeV2Activity()?.let {
it.getPet()?.apply {
// mViewBinding.ivHomePetTrackPetHead.load(imgurl)
mTrackerInfoViewModel.getPetTrackerInfo(it, deviceId)
mTrackMenuList[1].menuValue = ""
mTrackMenuList[2].menuValue = ""
mTrackMenuList[4].menuValue = ""
mTrackerInfoViewModel.getPetTrackerInfo(it, deviceId)
getBleTrackDeviceBean(false)?.let { ble ->
if (BleManager.getInstance().isConnected(macID)) {
@@ -395,7 +405,7 @@ class HomeTrackFragment :
mTrackMenuList[3].menuValue = ""
mTrackMenuList[3].isSwitch = false
}
mTrackMenuAdapter.notifyItemRangeChanged(1, 3)
mTrackMenuAdapter.notifyItemRangeChanged(1, 4)
}
}
}
@@ -455,7 +465,8 @@ class HomeTrackFragment :
mTrackStateList,
getString(R.string.txt_light),
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()
@@ -470,9 +481,8 @@ class HomeTrackFragment :
menuType = MultipleEntity.IMG_TEXT_IMG
)
ViewUtil.instance.addMenuBean(
mTrackMenuList,
getString(R.string.txt_power_off),
menuType = MultipleEntity.IMG_TEXT//, menuType = MultipleEntity.TEXT_NAME
mTrackMenuList, getString(R.string.txt_power_off)
// menuType = MultipleEntity.IMG_TEXT//, menuType = MultipleEntity.TEXT_NAME
)
}
@@ -564,17 +574,54 @@ class HomeTrackFragment :
}
}
mTrackStateList[4].let {
if (it.menuValue == getString(R.string.txt_connecting)) return
it.colorRedId = R.color.orange_color3
it.menuValue = if (BleManager.getInstance().isConnected(deviceMacId)) {
it.colorRedId = R.color.blue_color1
getString(R.string.txt_connected)
} else {
getString(R.string.txt_unconnect_no)
if (it.menuValue != getString(R.string.txt_connecting)) {
it.colorRedId = R.color.orange_color3
it.menuValue = if (BleManager.getInstance().isConnected(deviceMacId)) {
it.colorRedId = R.color.blue_color1
getString(R.string.txt_connected)
} else {
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 {
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.colorRedId = R.color.blue_color1
getString(R.string.tracker_manage_set_led_on)
@@ -582,18 +629,7 @@ class HomeTrackFragment :
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) {
@@ -681,7 +717,10 @@ class HomeTrackFragment :
*/
private fun updateConState(trackBleDevice: BleTrackDeviceBean) {
mBleTrackDeviceBean = trackBleDevice
mMapDeviceBean?.apply {
setLedControlState(this)
mHomePetTrackStateAdapter.notifyItemChanged(5)
}
if (trackBleDevice.conState == ConState.CONNECTED) {
if (isDFUCallback) {
showToast(R.string.txt_upgrade_success)
@@ -842,7 +881,7 @@ class HomeTrackFragment :
}
})
} 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
mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE
mViewBinding.ilHomeMapPetLocation.root.visibility = View.GONE
mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE
ViewUtil.instance.selectPetDialogShow(
mContext,

View File

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

View File

@@ -270,6 +270,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
// addPolyline(mGoogleMap!!, latLng)
// addUserAndPetLine(latLng)
refreshPetCurrentLocation(latLng, needMoveCamera = isMoveCamera)
isMoveCamera = false
// mRippleCircle?.apply {
// //一像素对应几米
@@ -293,6 +294,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
if (i == trackList.size - 1) {
// addUserAndPetLine(latLng)
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.SelectMapTypeDialog
import com.abbidot.tracker.ui.activity.WebViewActivity
import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.widget.TypefaceTextView
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
@@ -785,6 +784,7 @@ class ViewUtil private constructor() {
imageUrl: String = "",
colorRedId: Int = R.color.orange_color3,
isSwitch: Boolean = false,
type: Int = ConstantInt.Type0,
@MultipleEntity menuType: Int = MultipleEntity.TEXT
) {
val menuTxtBean = MenuTxtBean(name, value, menuType)
@@ -795,9 +795,10 @@ class ViewUtil private constructor() {
menuTxtBean.imageUrl = imageUrl
}
if (isSwitch) {
menuTxtBean.isSwitch = isSwitch
menuTxtBean.isSwitch = true
}
menuTxtBean.colorRedId = colorRedId
menuTxtBean.type = type
list.add(menuTxtBean)
}
@@ -1079,7 +1080,7 @@ class ViewUtil private constructor() {
else -> {
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))
@@ -1097,7 +1098,7 @@ class ViewUtil private constructor() {
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)) {
noConnectCallback()
} else if (btnString == context.getString(R.string.tracker_manage_set_ble_connect)) {
operateDialogTips(context, R.string.txt_disconnect_tips) {
SRBleUtil.instance.disconnectToMac(mac)
}
// operateDialogTips(context, R.string.txt_disconnect_tips) {
// 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()
.notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() {
override fun onNotifySuccess() {
LogUtil.e("打开蓝牙日志上报通道成功:${bleDevice.name}--${bleDevice.mac}")
LogUtil.e("打开蓝牙上报通道成功:${bleDevice.name}--${bleDevice.mac}")
openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID)
}
override fun onNotifyFailure(exception: BleException?) {
LogUtil.e("打开蓝牙日志上报通道失败:${bleDevice.mac}$exception")
LogUtil.e("打开蓝牙上报通道失败:${bleDevice.mac}$exception")
openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID)
}
override fun onCharacteristicChanged(data: ByteArray?) {
data?.apply {
val formatData = HexUtil.formatHexString(data, true)
LogUtil.e("接收蓝牙日志上报通道数据:${bleDevice.mac}$formatData")
LogUtil.e("接收蓝牙上报通道数据:${bleDevice.mac}$formatData")
val deviceData = ReceiveDeviceData(bleDevice, data, bleDevice.mac)
XEventBus.post(EventName.BleReport, deviceData)
}

View File

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

View File

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

View File

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

View File

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