1.新增蓝牙自动连接

2.led页面没有修改不会再次保存
3.优化直播蓝牙开启,然后立马关闭蓝牙情况
4.优化直播地图缩放比例不会随刷新而变化
This commit is contained in:
yezhiqiu
2025-12-03 14:18:36 +08:00
parent 314508e924
commit 83007612f0
21 changed files with 330 additions and 223 deletions

View File

@@ -1 +1 @@
#Thu Nov 13 11:09:24 CST 2025 #Fri Nov 28 15:02:35 CST 2025

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-Beta4" versionName "2.1.1-Beta7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -92,7 +92,7 @@ interface INetworkService {
@POST("user/sendEmail") @POST("user/sendEmail")
suspend fun getVerificationCode( suspend fun getVerificationCode(
@Field("email") email: String, @Field("type") type: Int @Field("email") email: String, @Field("type") type: Int
): BaseResponse<String> ): BaseResponse<UserBean>
/** /**
* 验证码验证 * 验证码验证

View File

@@ -23,17 +23,22 @@ import com.abbidot.tracker.R
import com.abbidot.tracker.adapter.ChangePetListDialogAdapter import com.abbidot.tracker.adapter.ChangePetListDialogAdapter
import com.abbidot.tracker.adapter.ViewPagerAdapter import com.abbidot.tracker.adapter.ViewPagerAdapter
import com.abbidot.tracker.base.BaseActivity import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.base.BaseDialog
import com.abbidot.tracker.bean.BleTrackDeviceBean import com.abbidot.tracker.bean.BleTrackDeviceBean
import com.abbidot.tracker.bean.FamilyBean
import com.abbidot.tracker.bean.PetBean import com.abbidot.tracker.bean.PetBean
import com.abbidot.tracker.bean.ReceiveDeviceData import com.abbidot.tracker.bean.ReceiveDeviceData
import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.constant.GetResultCallback import com.abbidot.tracker.constant.GetResultCallback
import com.abbidot.tracker.database.MyDatabase
import com.abbidot.tracker.databinding.ActivityHomeV2Binding import com.abbidot.tracker.databinding.ActivityHomeV2Binding
import com.abbidot.tracker.dialog.CommonDialog1
import com.abbidot.tracker.dialog.CommonListDialog import com.abbidot.tracker.dialog.CommonListDialog
import com.abbidot.tracker.receiver.BluetoothMonitorReceiver import com.abbidot.tracker.receiver.BluetoothMonitorReceiver
import com.abbidot.tracker.ui.DebugActivity import com.abbidot.tracker.ui.DebugActivity
import com.abbidot.tracker.ui.activity.device.AddNewTracker1Activity import com.abbidot.tracker.ui.activity.device.AddNewTracker1Activity
import com.abbidot.tracker.ui.activity.device.MyTrackerV2Activity
import com.abbidot.tracker.ui.fragment.account.AccountV2Fragment import com.abbidot.tracker.ui.fragment.account.AccountV2Fragment
import com.abbidot.tracker.ui.fragment.data.ActivityV2Fragment import com.abbidot.tracker.ui.fragment.data.ActivityV2Fragment
import com.abbidot.tracker.ui.fragment.data.RouteV2Fragment import com.abbidot.tracker.ui.fragment.data.RouteV2Fragment
@@ -47,9 +52,9 @@ import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.vm.ConnectionDeviceViewModel import com.abbidot.tracker.vm.ConnectionDeviceViewModel
import com.abbidot.tracker.vm.CountDownTimerViewModel import com.abbidot.tracker.vm.CountDownTimerViewModel
import com.abbidot.tracker.vm.DataViewModel import com.abbidot.tracker.vm.DataViewModel
import com.abbidot.tracker.vm.FamilyViewModel
import com.abbidot.tracker.vm.LogBleReportViewModel import com.abbidot.tracker.vm.LogBleReportViewModel
import com.abbidot.tracker.vm.SocketSendMessageViewModel import com.abbidot.tracker.vm.SocketSendMessageViewModel
import com.abbidot.tracker.vm.SubscriptionManageViewModel
import com.clj.fastble.BleManager import com.clj.fastble.BleManager
import com.google.android.material.navigation.NavigationBarView import com.google.android.material.navigation.NavigationBarView
import com.hjq.permissions.XXPermissions import com.hjq.permissions.XXPermissions
@@ -70,10 +75,10 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
val mDataViewModel: DataViewModel by viewModels() val mDataViewModel: DataViewModel by viewModels()
private val mAutomaticConnectionDeviceViewModel: ConnectionDeviceViewModel by viewModels() private val mAutomaticConnectionDeviceViewModel: ConnectionDeviceViewModel by viewModels()
private val mSubscriptionViewModel: SubscriptionManageViewModel by viewModels()
private val mLogBleReportViewModel: LogBleReportViewModel by viewModels() private val mLogBleReportViewModel: LogBleReportViewModel by viewModels()
private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels() private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels()
private val mSocketSendMessageViewModel: SocketSendMessageViewModel by viewModels() private val mSocketSendMessageViewModel: SocketSendMessageViewModel by viewModels()
private val mFamilyViewModel: FamilyViewModel by viewModels()
private var mChangePetDialog: CommonListDialog? = null private var mChangePetDialog: CommonListDialog? = null
@@ -88,6 +93,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
//是否请求过宠物数据 //是否请求过宠物数据
var isRequestPetData = false var isRequestPetData = false
private var mCountdownType = ConstantInt.SpecialType
private val mFragments = mutableListOf<Fragment>( private val mFragments = mutableListOf<Fragment>(
ActivityV2Fragment.newInstance(this), ActivityV2Fragment.newInstance(this),
@@ -137,16 +143,22 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
it.itemIconTintList = null it.itemIconTintList = null
it.setOnItemSelectedListener(this) it.setOnItemSelectedListener(this)
} }
mPetList = mutableListOf() mPetList = mutableListOf()
mChangePetListDialogAdapter = ChangePetListDialogAdapter(mContext, mPetList).apply { mChangePetListDialogAdapter = ChangePetListDialogAdapter(mContext, mPetList).apply {
setOnChangeClickListener(this@HomeV2Activity) setOnChangeClickListener(this@HomeV2Activity)
} }
//smoothScroll设为false,不显示动画,关闭预加载? true显示过渡动画 //smoothScroll设为false,不显示动画,关闭预加载? true显示过渡动画
mViewBinding.homeV2ViewPager2.setCurrentItem(2, false) mViewBinding.homeV2ViewPager2.setCurrentItem(2, false)
setLineShow(2) setLineShow(2)
//出现闪退,5秒退出APP
val isCrash = MMKVUtil.getBoolean(MMKVKey.isCrash, false)
if (isCrash) {
MMKVUtil.putBoolean(MMKVKey.isCrash, false)
showToast(R.string.txt_show_crash)
mCountdownType = ConstantInt.Type0
mCountDownTimerViewModel.startCountDown(6)
} else {
//注册监听蓝牙开关广播 //注册监听蓝牙开关广播
mBleListenerReceiver = BluetoothMonitorReceiver() mBleListenerReceiver = BluetoothMonitorReceiver()
val intentFilter = IntentFilter() val intentFilter = IntentFilter()
@@ -160,21 +172,6 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
//设置bugly的用户id //设置bugly的用户id
CrashReport.setUserId(MMKVUtil.getString(MMKVKey.Email)) CrashReport.setUserId(MMKVUtil.getString(MMKVKey.Email))
//自动重启APP
// val intent = baseContext.packageManager.getLaunchIntentForPackage(baseContext.packageName)
// //与正常页面跳转一样可传递序列化数据,在Launch页面内获得
// intent!!.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
// intent.putExtra("REBOOT", "reboot")
// startActivity(intent)
//出现闪退,5秒退出APP
val isCrash = MMKVUtil.getBoolean(MMKVKey.isCrash, false)
if (isCrash) {
MMKVUtil.putBoolean(MMKVKey.isCrash, false)
showToast(R.string.txt_show_crash)
mCountDownTimerViewModel.startCountDown(6)
} else {
//预先加载相册,防止上传头像几千张照片加载慢 //预先加载相册,防止上传头像几千张照片加载慢
XXPermissions.with(this).permission(PermissionLists.getReadMediaImagesPermission()) XXPermissions.with(this).permission(PermissionLists.getReadMediaImagesPermission())
.request { _, allGranted -> .request { _, allGranted ->
@@ -201,8 +198,22 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
//出现闪退,5秒退出APP //出现闪退,5秒退出APP
mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) { mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) {
//自动重启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() finish()
System.gc() System.gc()
} else if (mCountdownType == ConstantInt.Type1) {
LogUtil.e("自动连接蓝牙倒计时结束")
if (SRBleUtil.instance.isBleEnable(mContext)) {
autoConnectDevice()
mCountDownTimerViewModel.startCountDown(20)
}
}
} }
//退出登录 //退出登录
XEventBus.observe(this, EventName.LogOut) { XEventBus.observe(this, EventName.LogOut) {
@@ -215,8 +226,15 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
//接收开蓝牙操作,然后搜索连接设备 //接收开蓝牙操作,然后搜索连接设备
XEventBus.observe(this, EventName.BluetoothSwitch) { conState: Int -> XEventBus.observe(this, EventName.BluetoothSwitch) { conState: Int ->
if (conState == ConState.BLUETOOTH_ON) { if (conState == ConState.BLUETOOTH_ON) {
// mAutomaticConnectionDeviceViewModel.autoConnectBleDevice(mContext)
autoConnectDevice() autoConnectDevice()
} else if (conState == ConState.BLUETOOTH_OFF) {
//处理高版本关闭蓝牙开关,不断开蓝牙连接的情况
getPet(false)?.apply {
BleTrackDeviceBean().let { trackBle ->
trackBle.mac = macID
XEventBus.post(EventName.ConnectDeviceState, trackBle)
}
}
} }
} }
//接收蓝牙连接状态 //接收蓝牙连接状态
@@ -225,14 +243,19 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
//蓝牙连接断开上传日志 //蓝牙连接断开上传日志
if (ble.mac == macID) { if (ble.mac == macID) {
if (ble.conState == ConState.CONNECTED) { if (ble.conState == ConState.CONNECTED) {
mCountDownTimerViewModel.stopCountDown()
//蓝牙连接就去连接socket //蓝牙连接就去连接socket
mBleReportManage.dealBleReportData(macID, null) mBleReportManage.dealBleReportData(macID, null)
} else { } else {
mLogBleReportViewModel.uploadLog(mContext, macID) mLogBleReportViewModel.uploadLog(mContext, macID)
LogUtil.e("15秒监听蓝牙自动连接")
mCountdownType = ConstantInt.Type1
mCountDownTimerViewModel.startCountDown(15)
} }
} }
} }
} }
//更新套餐数据 //更新套餐数据
XEventBus.observe(this, EventName.RefreshPackage) { XEventBus.observe(this, EventName.RefreshPackage) {
mDataViewModel.getHomeBindPetList(this) mDataViewModel.getHomeBindPetList(this)
@@ -241,6 +264,10 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
XEventBus.observe(this, EventName.RefreshPet) { XEventBus.observe(this, EventName.RefreshPet) {
mDataViewModel.getHomeBindPetList(this) mDataViewModel.getHomeBindPetList(this)
} }
//刷新下邀请家人数据
XEventBus.observe(this, EventName.RefreshHomeList) {
mDataViewModel.getHomeBindPetList(this)
}
//删除宠物 //删除宠物
XEventBus.observe(this, EventName.DeletePet) { XEventBus.observe(this, EventName.DeletePet) {
mSelectPetPosition = 0 mSelectPetPosition = 0
@@ -308,6 +335,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
it.getOrNull()?.apply { it.getOrNull()?.apply {
setPetData(this) setPetData(this)
} }
mFamilyViewModel.getDeviceInviteInfo(this@HomeV2Activity)
} }
override fun onRequestError(exceptionCode: String?) { override fun onRequestError(exceptionCode: String?) {
@@ -322,6 +350,17 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
isShowRequestErrorTip = mNetworkRequestsFailRetryCount == mNetworkRequestsFailMaxCount isShowRequestErrorTip = mNetworkRequestsFailRetryCount == mNetworkRequestsFailMaxCount
) )
} }
//获取设备邀请信息
mFamilyViewModel.mInviteInfoLiveData.observe(this) {
dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) {
it.getOrNull()?.apply {
if (deleteArray.isNotEmpty()) showDeleteInviteDialog(deleteArray)
if (inviteArray.isNotEmpty()) showInviteDialog(inviteArray)
}
}
})
}
} }
private fun setPetData(petList: MutableList<PetBean>) { private fun setPetData(petList: MutableList<PetBean>) {
@@ -373,6 +412,65 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
} }
} }
/**
* 显示被删除邀请的弹窗
*/
private fun showDeleteInviteDialog(deleteArray: MutableList<FamilyBean>) {
lifecycleScope.launch(Dispatchers.IO) {
val myDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DeviceTableName)
myDeviceDb?.apply {
for (deviceDb in myDeviceDb) {
for (item in deleteArray) {
if (deviceDb.deviceId == item.deviceId) {
MyDatabase.deviceDao().delete(deviceDb)
LogUtil.e("删除了邀请的设备")
}
}
}
}
val newDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DeviceTableName)
newDeviceDb?.apply {
LogUtil.e("删去了邀请,还剩${newDeviceDb.size}下个设备")
}
}
CommonDialog1(
mContext,
getString(R.string.txt_setting_notification),
getString(R.string.txt_view_access),
false,
okClickListener = object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
if (mPetList.size == 0) {
noSharePet()
} else {
onChangeClick(0)
}
}
}).show()
}
/**
* 显示被邀请通知弹窗
*/
private fun showInviteDialog(inviteArray: MutableList<FamilyBean>) {
for (item in inviteArray) {
val content = String.format(
getString(R.string.txt_invites_you_check), item.userName, item.petName
)
CommonDialog1(
mContext,
getString(R.string.txt_setting_notification),
content,
false,
okClickListener = object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
startActivity(Intent(mContext, MyTrackerV2Activity::class.java))
}
}).show()
}
}
/** /**
* 套餐不可用状态 * 套餐不可用状态
*/ */
@@ -402,10 +500,10 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
*/ */
private fun checkPermissions() { private fun checkPermissions() {
val checkBleOpen = MMKVUtil.getBoolean(MMKVKey.isFirstCheckBleOpen, true) val checkBleOpen = MMKVUtil.getBoolean(MMKVKey.isFirstCheckBleOpen, true)
if (checkBleOpen) MMKVUtil.putBoolean(MMKVKey.isFirstCheckBleOpen, false)
Util.checkBluetoothPermissionsEnabled(mContext, { Util.checkBluetoothPermissionsEnabled(mContext, {
// mAutomaticConnectionDeviceViewModel.autoConnectBleDevice(mContext) // mAutomaticConnectionDeviceViewModel.autoConnectBleDevice(mContext)
}, isCheckBleOpen = checkBleOpen) }, isCheckBleOpen = checkBleOpen)
if (checkBleOpen) MMKVUtil.putBoolean(MMKVKey.isFirstCheckBleOpen, false)
} }
/** /**
@@ -533,6 +631,8 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
mAutomaticConnectionDeviceViewModel.connectDeviceToMac( mAutomaticConnectionDeviceViewModel.connectDeviceToMac(
this@HomeV2Activity, macID, false this@HomeV2Activity, macID, false
) )
mCountdownType = ConstantInt.Type1
mCountDownTimerViewModel.startCountDown(30)
} }
} }
} }

View File

@@ -189,7 +189,7 @@ class LoginV2Activity : BaseActivity<ActivityLoginV2Binding>(ActivityLoginV2Bind
} }
} }
if (TextUtils.isEmpty(email)) { if (TextUtils.isEmpty(email) || !Utils.isValidEmail(email)) {
isSure = false isSure = false
ViewUtil.instance.setInputViewErrorShow( ViewUtil.instance.setInputViewErrorShow(
mContext, ilLoginV2EmailAddress.rlEtInputLayout, tvEmailErrorTipLogin mContext, ilLoginV2EmailAddress.rlEtInputLayout, tvEmailErrorTipLogin

View File

@@ -108,7 +108,8 @@ class UserProfileActivity :
mTakePhotoAndCompressViewModel.registerCropImageActivityResult(this) mTakePhotoAndCompressViewModel.registerCropImageActivityResult(this)
mUserViewModel.getCountryCodes(this) // mUserViewModel.getCountryCodes(this)
mUserViewModel.getUserInfo(this@UserProfileActivity)
} }
override fun onResume() { override fun onResume() {
@@ -124,19 +125,19 @@ class UserProfileActivity :
override fun liveDataObserve() { override fun liveDataObserve() {
mUserViewModel.apply { mUserViewModel.apply {
//获取国家代码 //获取国家代码
mCountryCodeLiveData.observe(this@UserProfileActivity) { // mCountryCodeLiveData.observe(this@UserProfileActivity) {
getUserInfo(this@UserProfileActivity) // getUserInfo(this@UserProfileActivity)
dealRequestResult(it, object : GetResultCallback { // dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) { // override fun onResult(any: Any) {
it.getOrNull()?.apply { // it.getOrNull()?.apply {
mCountryCommon.setCountryCodeData(this) // mCountryCommon.setCountryCodeData(this)
val countryCode = MMKVUtil.getString(MMKVKey.CountryCode) // val countryCode = MMKVUtil.getString(MMKVKey.CountryCode)
val country = mCountryCommon.codeToCountry(countryCode) // val country = mCountryCommon.codeToCountry(countryCode)
mViewBinding.ilUserProfileCountry.etInputContent.setText(country) // mViewBinding.ilUserProfileCountry.etInputContent.setText(country)
} // }
} // }
}) // })
} // }
//获取用户信息 //获取用户信息
mUserInfoLiveData.observe(this@UserProfileActivity) { mUserInfoLiveData.observe(this@UserProfileActivity) {
dealRequestResult(it, object : GetResultCallback { dealRequestResult(it, object : GetResultCallback {
@@ -162,7 +163,9 @@ class UserProfileActivity :
val data = it.getOrNull() val data = it.getOrNull()
// showToast(R.string.txt_upload_successful) // showToast(R.string.txt_upload_successful)
mUploadImageUrl = data!! mUploadImageUrl = data!!
mViewBinding.ilUserProfileHeadLayout.ilPetProfileHead.appHeadImage.load(mUploadImageUrl) mViewBinding.ilUserProfileHeadLayout.ilPetProfileHead.appHeadImage.load(
mUploadImageUrl
)
userProfileSave() userProfileSave()
} }
}) })
@@ -215,7 +218,7 @@ class UserProfileActivity :
private fun userProfileSave() { private fun userProfileSave() {
mViewBinding.apply { mViewBinding.apply {
val name = ilUserProfileNameLayout.etInputContent.text.toString() val name = ilUserProfileNameLayout.etInputContent.text.toString()
val country = ilUserProfileCountry.etInputContent.text.toString() // val country = ilUserProfileCountry.etInputContent.text.toString()
val email = ilUserProfileEmailLayout.etInputContent.text.toString() val email = ilUserProfileEmailLayout.etInputContent.text.toString()
var isSure = true var isSure = true
if (TextUtils.isEmpty(name)) { if (TextUtils.isEmpty(name)) {
@@ -224,14 +227,14 @@ class UserProfileActivity :
mContext, ilUserProfileNameLayout.rlEtInputLayout, tvUserProfileNameErrorTip mContext, ilUserProfileNameLayout.rlEtInputLayout, tvUserProfileNameErrorTip
) )
} }
if (TextUtils.isEmpty(country)) { // if (TextUtils.isEmpty(country)) {
isSure = false // isSure = false
ViewUtil.instance.setInputViewErrorShow( // ViewUtil.instance.setInputViewErrorShow(
mContext, // mContext,
ilUserProfileCountry.rlEtInputLayout, // ilUserProfileCountry.rlEtInputLayout,
tvUserProfileSelectCountryErrorTip // tvUserProfileSelectCountryErrorTip
) // )
} // }
if (TextUtils.isEmpty(email) || !Utils.isValidEmail(email)) { if (TextUtils.isEmpty(email) || !Utils.isValidEmail(email)) {
isSure = false isSure = false
ViewUtil.instance.setInputViewErrorShow( ViewUtil.instance.setInputViewErrorShow(
@@ -241,11 +244,7 @@ class UserProfileActivity :
if (!isSure) return if (!isSure) return
mUserViewModel.updateUserInfo( mUserViewModel.updateUserInfo(
this@UserProfileActivity, this@UserProfileActivity, "", mUploadImageUrl, mCountryCommon.getCountryCode(), name
"",
mUploadImageUrl,
mCountryCommon.getCountryCode(),
name
) )
} }
} }

View File

@@ -61,6 +61,8 @@ class MyTrackerV2Activity :
override fun getTopBar() = mViewBinding.ilMyTrackerV2TopBar.titleTopBar override fun getTopBar() = mViewBinding.ilMyTrackerV2TopBar.titleTopBar
override fun initData() { override fun initData() {
//刷新下邀请家人的数据
XEventBus.post(EventName.RefreshHomeList)
super.initData() super.initData()
setTopBarTitle(R.string.tracker_manage_mine) setTopBarTitle(R.string.tracker_manage_mine)
setLeftBackImage(R.drawable.icon_white_back_svg) setLeftBackImage(R.drawable.icon_white_back_svg)

View File

@@ -46,6 +46,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
private var mPetBean: PetBean? = null private var mPetBean: PetBean? = null
private var mMapDeviceBean: MapDeviceBean? = null private var mMapDeviceBean: MapDeviceBean? = null
private var mOldMapDeviceBean: MapDeviceBean? = null
private var mBleTrackDeviceBean: BleTrackDeviceBean? = null private var mBleTrackDeviceBean: BleTrackDeviceBean? = null
private lateinit var mLedLightColorAdapter: LedLightColorAdapter private lateinit var mLedLightColorAdapter: LedLightColorAdapter
private lateinit var mLedModeList: MutableList<String> private lateinit var mLedModeList: MutableList<String>
@@ -76,19 +77,6 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
null, null,
getString(R.string.tracker_manage_set_led) getString(R.string.tracker_manage_set_led)
) )
mViewBinding.ledLightOpenAndClose.switch.apply {
setOnCheckedChangeListener { _, isChecked ->
mMapDeviceBean?.let {
if (isChecked) {
it.ledSwitch = ConstantInt.Open
setBleLedMode(it.ledMode)
} else {
it.ledSwitch = ConstantInt.Close
setBleLedMode(0)
}
}
}
}
val builder = ViewUtil.instance.showBottomSheetList(mContext, { dialog, _, position, _ -> val builder = ViewUtil.instance.showBottomSheetList(mContext, { dialog, _, position, _ ->
mMapDeviceBean?.apply { mMapDeviceBean?.apply {
@@ -171,7 +159,8 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
ledLightBluetoothTips.trbBleConnectState, ledLightBluetoothTips.trbBleConnectState,
btnLedLightSetSave, btnLedLightSetSave,
btnLedLightIssue, btnLedLightIssue,
ilLedLightIssueLayout.tvCloseIssueBtn ilLedLightIssueLayout.tvCloseIssueBtn,
mViewBinding.ledLightOpenAndClose.switch
) )
} }
@@ -191,6 +180,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
val data = it.getOrNull() val data = it.getOrNull()
data?.apply { data?.apply {
mMapDeviceBean = data mMapDeviceBean = data
mOldMapDeviceBean = data.copy()
setDeviceData(data) setDeviceData(data)
} }
} }
@@ -260,15 +250,27 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
} }
override fun leftBackOnClick() { override fun leftBackOnClick() {
if (null == mMapDeviceBean || null == mOldMapDeviceBean) {
super.leftBackOnClick()
return
}
if (isFinishSave) return if (isFinishSave) return
//是否是蓝牙连接了,修改设备数据返回,同步服务器 //是否是蓝牙连接了,修改设备数据返回,同步服务器
if (null != mBleTrackDeviceBean) { if (null != mBleTrackDeviceBean) {
mMapDeviceBean?.apply {
mOldMapDeviceBean?.let {
if (it == mMapDeviceBean) {
super.leftBackOnClick()
} else {
//判断是否有蓝牙连接 //判断是否有蓝牙连接
if (BleManager.getInstance().isConnected(mBleTrackDeviceBean!!.bleDevice)) { if (BleManager.getInstance().isConnected(mBleTrackDeviceBean!!.bleDevice)) {
finishAndSave(ConstantInt.Type1) finishAndSave(ConstantInt.Type1)
} else { } else {
super.leftBackOnClick() super.leftBackOnClick()
} }
}
}
}
} else { } else {
super.leftBackOnClick() super.leftBackOnClick()
} }
@@ -278,6 +280,10 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
* 保存设置数据 * 保存设置数据
*/ */
private fun finishAndSave(modeType: Int) { private fun finishAndSave(modeType: Int) {
if (null == mMapDeviceBean) {
finish()
return
}
mMapDeviceBean?.apply { mMapDeviceBean?.apply {
isFinishSave = true isFinishSave = true
mLedLightViewModel.setLedLight(this@LedLightActivity, this, modeType) mLedLightViewModel.setLedLight(this@LedLightActivity, this, modeType)
@@ -365,6 +371,20 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
} }
} }
private fun setLedSwitch() {
mViewBinding.ledLightOpenAndClose.switch.apply {
mMapDeviceBean?.let {
if (isChecked) {
it.ledSwitch = ConstantInt.Open
setBleLedMode(it.ledMode)
} else {
it.ledSwitch = ConstantInt.Close
setBleLedMode(0)
}
}
}
}
override fun onClick(v: View?) { override fun onClick(v: View?) {
mViewBinding.apply { mViewBinding.apply {
when (v) { when (v) {
@@ -380,6 +400,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
btnLedLightIssue -> showLedIssue() btnLedLightIssue -> showLedIssue()
ilLedLightIssueLayout.tvCloseIssueBtn -> showLedIssue() ilLedLightIssueLayout.tvCloseIssueBtn -> showLedIssue()
ledLightOpenAndClose.switch -> setLedSwitch()
} }
} }
} }

View File

@@ -134,7 +134,8 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
mContext, mContext,
ilLiveV3MapPetLocation, ilLiveV3MapPetLocation,
llLiveV3MapDeviceBatteryLayout, llLiveV3MapDeviceBatteryLayout,
Utils.DATE_FORMAT_PATTERN_EN12 Utils.DATE_FORMAT_PATTERN_EN12,
isLiveJump
) { mapLoadOk() } ) { mapLoadOk() }
ViewUtil.instance.setMapSwitchLocationButtonImage( ViewUtil.instance.setMapSwitchLocationButtonImage(
ivMapLiveV2RefreshBtn, mShowCenterLocation ivMapLiveV2RefreshBtn, mShowCenterLocation
@@ -349,6 +350,19 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
} }
} }
} }
// //接收开蓝牙操作,然后搜索连接设备
// XEventBus.observe(this, EventName.BluetoothSwitch) { conState: Int ->
// if (conState == ConState.BLUETOOTH_OFF) {
// //隐藏蓝牙nearby
// mViewBinding.ilLiveV3MapDeviceMsg.root.visibility = View.GONE
// //处理高版本关闭蓝牙开关,不断开蓝牙连接的情况
// mMapDeviceBean?.apply {
// val trackBle = BleTrackDeviceBean()
// trackBle.mac = deviceMacId
// updateConState(trackBle)
// }
// }
// }
//搜索蓝牙的设备状态 //搜索蓝牙的设备状态
XEventBus.observe(this, EventName.ActionConDeviceState) { conState: Int -> XEventBus.observe(this, EventName.ActionConDeviceState) { conState: Int ->
if (conState == ConState.DEVICE_NOT_FOUND) { if (conState == ConState.DEVICE_NOT_FOUND) {
@@ -588,12 +602,17 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
openNetLive(ConstantInt.Type2) openNetLive(ConstantInt.Type2)
} }
} else { } else {
if (isLiveJump && isStartLive) { if (isLiveJump) {
if (isStartLive) {
mPetBean?.apply { mPetBean?.apply {
//直播开启后,就去获取直播轨迹 //直播开启后,就去获取直播轨迹
mMapLiveViewModel.mGetPetLivePointTimeStamp = System.currentTimeMillis() / 1000 mMapLiveViewModel.mGetPetLivePointTimeStamp =
System.currentTimeMillis() / 1000
mMapLiveViewModel.getPetLivePoint(deviceId) mMapLiveViewModel.getPetLivePoint(deviceId)
} }
} else {
openNetLive(ConstantInt.Type2)
}
} }
} }
} }
@@ -705,7 +724,7 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
/** /**
* 显示选择宠物弹窗 * 显示选择宠物
*/ */
private fun showPetNameAndHead() { private fun showPetNameAndHead() {
mPetBean?.apply { mPetBean?.apply {
@@ -752,6 +771,11 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
).toString() + mSpeedUnit ).toString() + mSpeedUnit
ilLiveV2OperateLayout.tvLiveV2Speed.text = speedStr ilLiveV2OperateLayout.tvLiveV2Speed.text = speedStr
mMapDeviceBean?.let { m ->
isCloseMsg = m.isCloseMsg
isCloseBattery = m.isCloseBattery
canShowBattery = m.canShowBattery
}
setMapDeviceBean(this) setMapDeviceBean(this)
val isOpen = ledSwitch == ConstantInt.Open val isOpen = ledSwitch == ConstantInt.Open
ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.cbDeviceLightSwitch.isChecked = isOpen ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.cbDeviceLightSwitch.isChecked = isOpen
@@ -831,9 +855,10 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
*/ */
private fun showAndHideFindLayout() { private fun showAndHideFindLayout() {
mViewBinding.apply { mViewBinding.apply {
ilLiveV3MapPetLocation.root.visibility = View.GONE llLiveV3MapDeviceBatteryLayout.visibility = View.INVISIBLE
val relativeLayout = ivMapLiveV2RefreshBtn.layoutParams as RelativeLayout.LayoutParams val relativeLayout = ivMapLiveV2RefreshBtn.layoutParams as RelativeLayout.LayoutParams
ivMapLiveV2RefreshBtn.visibility = View.GONE ivMapLiveV2RefreshBtn.visibility = View.GONE
ilLiveV3MapPetLocation.root.visibility = View.INVISIBLE
if (ilLiveV2BluetoothFindDevice.root.isGone) { if (ilLiveV2BluetoothFindDevice.root.isGone) {
//找蓝牙设备布局显示 //找蓝牙设备布局显示
YoYo.with(Techniques.BounceInUp).duration(800).onStart { YoYo.with(Techniques.BounceInUp).duration(800).onStart {
@@ -857,16 +882,16 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
YoYo.with(Techniques.BounceInUp).duration(800).delay(400).onEnd { YoYo.with(Techniques.BounceInUp).duration(800).delay(400).onEnd {
//蓝牙图标按钮显示动画 //蓝牙图标按钮显示动画
ViewUtil.instance.viewShowFadeInAnimation(ivMapLiveV2BluetoothBtn) ViewUtil.instance.viewShowFadeInAnimation(ivMapLiveV2BluetoothBtn)
ViewUtil.instance.viewShowFadeInAnimation(ilLiveV3MapPetLocation.root)
//刷新定位按钮显示动画 //刷新定位按钮显示动画
ViewUtil.instance.viewShowFadeInAnimation(ivMapLiveV2RefreshBtn) ViewUtil.instance.viewShowFadeInAnimation(ivMapLiveV2RefreshBtn)
}.playOn(ilLiveV2OperateLayout.root) }.playOn(ilLiveV2OperateLayout.root)
relativeLayout.removeRule(RelativeLayout.ABOVE) relativeLayout.removeRule(RelativeLayout.ABOVE)
relativeLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM) relativeLayout.addRule(RelativeLayout.ABOVE, R.id.il_live_v3_map_pet_location)
} }
root.postDelayed({ root.postDelayed({
ilLiveV3MapPetLocation.root.visibility = View.VISIBLE
mHomeMapCommon.setMarkerInfoViewOffset() mHomeMapCommon.setMarkerInfoViewOffset()
}, 1000) }, 1000)
} }
@@ -877,23 +902,24 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
*/ */
private fun showLiveIssue() { private fun showLiveIssue() {
mViewBinding.apply { mViewBinding.apply {
ilLiveV3MapPetLocation.root.visibility = View.GONE llLiveV3MapDeviceBatteryLayout.visibility = View.INVISIBLE
if (ilMapLiveV2IssueLayout.root.isGone) { if (ilMapLiveV2IssueLayout.root.isGone) {
YoYo.with(Techniques.BounceInUp).duration(700).onStart { YoYo.with(Techniques.BounceInUp).duration(700).onStart {
ilLiveV2OperateLayout.root.visibility = View.GONE ilLiveV2OperateLayout.root.visibility = View.GONE
ilLiveV3MapPetLocation.root.visibility = View.INVISIBLE
ilMapLiveV2IssueLayout.root.visibility = View.VISIBLE ilMapLiveV2IssueLayout.root.visibility = View.VISIBLE
}.playOn(ilMapLiveV2IssueLayout.root) }.playOn(ilMapLiveV2IssueLayout.root)
} else { } else {
YoYo.with(Techniques.SlideOutDown).duration(600).onEnd { YoYo.with(Techniques.SlideOutDown).duration(600).onEnd {
ilMapLiveV2IssueLayout.root.visibility = View.GONE ilMapLiveV2IssueLayout.root.visibility = View.GONE
YoYo.with(Techniques.BounceInUp).duration(600).onStart { YoYo.with(Techniques.BounceInUp).duration(600).onStart {
ilLiveV3MapPetLocation.root.visibility = View.VISIBLE
ilLiveV2OperateLayout.root.visibility = View.VISIBLE ilLiveV2OperateLayout.root.visibility = View.VISIBLE
}.playOn(ilLiveV2OperateLayout.root) }.playOn(ilLiveV2OperateLayout.root)
}.playOn(ilMapLiveV2IssueLayout.root) }.playOn(ilMapLiveV2IssueLayout.root)
} }
root.postDelayed({ root.postDelayed({
ilLiveV3MapPetLocation.root.visibility = View.VISIBLE
mHomeMapCommon.setMarkerInfoViewOffset() mHomeMapCommon.setMarkerInfoViewOffset()
}, 1000) }, 1000)
} }
@@ -1013,11 +1039,15 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
ilLiveV2OperateLayout.btnLiveV2Issue -> showLiveIssue() ilLiveV2OperateLayout.btnLiveV2Issue -> showLiveIssue()
ilMapLiveV2IssueLayout.tvCloseIssueBtn -> showLiveIssue() ilMapLiveV2IssueLayout.tvCloseIssueBtn -> showLiveIssue()
ilLiveV2BluetoothFindDevice.ivLiveV2FindDeviceSound -> setSound() ilLiveV2BluetoothFindDevice.ivLiveV2FindDeviceSound -> setSound()
ilLiveV3MapDeviceBatteryLayout.ivDeviceCloseBtn -> llLiveV3MapDeviceBatteryLayout.visibility = ilLiveV3MapDeviceBatteryLayout.ivDeviceCloseBtn -> {
View.INVISIBLE mMapDeviceBean?.isCloseBattery = true
llLiveV3MapDeviceBatteryLayout.visibility = View.INVISIBLE
}
ilLiveV3MapDeviceMsg.ivDeviceMsgCloseBtn -> ilLiveV3MapDeviceMsg.root.visibility = ilLiveV3MapDeviceMsg.ivDeviceMsgCloseBtn -> {
View.GONE mMapDeviceBean?.isCloseMsg = true
ilLiveV3MapDeviceMsg.root.visibility = View.GONE
}
} }
} }
} }

View File

@@ -424,13 +424,13 @@ class PetProfileActivity :
//接收身高设置页面的值 //接收身高设置页面的值
it.data?.extras?.getFloat(ConstantString.PetHeight)?.apply { it.data?.extras?.getFloat(ConstantString.PetHeight)?.apply {
mViewBinding.ilPetProfileHeight.etInputContent.setText("$this") mViewBinding.ilPetProfileHeight.etInputContent.setText("$this")
mPetBean?.height = Util.convertMetricUnits(this, ConstantInt.Type0,4) mPetBean?.height = Util.convertMetricUnits(this, ConstantInt.Type0, 4)
} }
} else if (it.resultCode == ResultCode.ResultCode_3) { } else if (it.resultCode == ResultCode.ResultCode_3) {
//接收体重设置页面的值 //接收体重设置页面的值
it.data?.extras?.getFloat(ConstantString.PetWeight)?.apply { it.data?.extras?.getFloat(ConstantString.PetWeight)?.apply {
mViewBinding.ilPetProfileWeight.etInputContent.setText("$this") mViewBinding.ilPetProfileWeight.etInputContent.setText("$this")
mPetBean?.weight = Util.convertMetricUnits(this, ConstantInt.Type1,4) mPetBean?.weight = Util.convertMetricUnits(this, ConstantInt.Type1, 4)
} }
} }
} }
@@ -502,7 +502,7 @@ class PetProfileActivity :
if (any is String) { if (any is String) {
mViewBinding.ilPetProfileWeight.etInputContent.setText(any) mViewBinding.ilPetProfileWeight.etInputContent.setText(any)
weight = Util.convertMetricUnits( weight = Util.convertMetricUnits(
any.toFloat(), ConstantInt.Type1,4 any.toFloat(), ConstantInt.Type1, 4
) )
} }
} }

View File

@@ -31,6 +31,7 @@ class HomeMapCommonV3 @Inject constructor() : BaseMapCommon() {
locationLayoutViewBinding: LayoutPetLocationInfoBinding, locationLayoutViewBinding: LayoutPetLocationInfoBinding,
deviceBatteryLayout: ViewGroup, deviceBatteryLayout: ViewGroup,
petAddressTimeFormat: String, petAddressTimeFormat: String,
isGeocode: Boolean,
mapLoadOk: () -> Unit mapLoadOk: () -> Unit
): Fragment { ): Fragment {
return if (AppUtils.isChina(AppUtils.SWITCH_MAP_TYPE)) { return if (AppUtils.isChina(AppUtils.SWITCH_MAP_TYPE)) {
@@ -42,6 +43,7 @@ class HomeMapCommonV3 @Inject constructor() : BaseMapCommon() {
locationLayoutViewBinding, locationLayoutViewBinding,
deviceBatteryLayout, deviceBatteryLayout,
petAddressTimeFormat, petAddressTimeFormat,
isGeocode,
mapLoadOk mapLoadOk
) )
mHomeMapGoogleMapFragment!! mHomeMapGoogleMapFragment!!

View File

@@ -168,6 +168,7 @@ class CreateAccountV2OneFragment : BaseFragment<FragmentCreateAccountV2OneBindin
btnCreateAccountV2Continue.isEnabled = false btnCreateAccountV2Continue.isEnabled = false
mCreateAccountV2Activity.isInterceptNetErrorCodeTip = true mCreateAccountV2Activity.isInterceptNetErrorCodeTip = true
mCreateAccountV2Activity.hideInputMethod(root)
mRegisterViewModel.getEmailCode(mCreateAccountV2Activity, email, 1) mRegisterViewModel.getEmailCode(mCreateAccountV2Activity, email, 1)
} }
} }

View File

@@ -32,7 +32,7 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels() private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels()
private val mRegisterViewModel: UserProfileViewModel by viewModels() private val mRegisterViewModel: UserProfileViewModel by viewModels()
private val mResendCodeTime = 5 * 60 + 1 private val mResendCodeTime = 5 * 60
private var mEmail = "" private var mEmail = ""
private var mBtnString = "" private var mBtnString = ""
private var mEmailCodeType = 0 private var mEmailCodeType = 0
@@ -57,7 +57,13 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
fun setEmail(email: String) { fun setEmail(email: String) {
mEmail = email mEmail = email
//返回上一个页面修改邮箱,再次回到需要更新邮箱显示 //返回上一个页面修改邮箱,再次回到需要更新邮箱显示
if (isResumed) formatEmail() if (isResumed) {
mViewBinding.vetForgotPasswordV2EditText.clearContent()
mCountDownTimerViewModel.stopCountDown()
setResendCodeBtnEnabled(false)
mCountDownTimerViewModel.startCountDown(mResendCodeTime.toLong())
formatEmail()
}
} }
override fun initData() { override fun initData() {

View File

@@ -2,6 +2,7 @@ package com.abbidot.tracker.ui.fragment.map
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Typeface
import android.location.LocationManager import android.location.LocationManager
import android.provider.Settings import android.provider.Settings
import android.view.View import android.view.View
@@ -9,7 +10,6 @@ import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.commit import androidx.fragment.app.commit
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import com.abbidot.baselibrary.constant.ConState import com.abbidot.baselibrary.constant.ConState
import com.abbidot.baselibrary.constant.EventName import com.abbidot.baselibrary.constant.EventName
import com.abbidot.baselibrary.constant.MMKVKey import com.abbidot.baselibrary.constant.MMKVKey
@@ -26,31 +26,25 @@ import com.abbidot.tracker.base.BaseFragment
import com.abbidot.tracker.bean.BleReportDataBean import com.abbidot.tracker.bean.BleReportDataBean
import com.abbidot.tracker.bean.BleTrackDeviceBean import com.abbidot.tracker.bean.BleTrackDeviceBean
import com.abbidot.tracker.bean.DataBean import com.abbidot.tracker.bean.DataBean
import com.abbidot.tracker.bean.FamilyBean
import com.abbidot.tracker.bean.MapDeviceBean import com.abbidot.tracker.bean.MapDeviceBean
import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.constant.GetResultCallback import com.abbidot.tracker.constant.GetResultCallback
import com.abbidot.tracker.database.MyDatabase
import com.abbidot.tracker.databinding.FragmentMapV3Binding import com.abbidot.tracker.databinding.FragmentMapV3Binding
import com.abbidot.tracker.dialog.CommonDialog1 import com.abbidot.tracker.dialog.CommonDialog1
import com.abbidot.tracker.dialog.SelectMapTypeDialog import com.abbidot.tracker.dialog.SelectMapTypeDialog
import com.abbidot.tracker.ui.activity.HomeV2Activity import com.abbidot.tracker.ui.activity.HomeV2Activity
import com.abbidot.tracker.ui.activity.device.MyTrackerV2Activity
import com.abbidot.tracker.ui.activity.map.LiveActivityV3 import com.abbidot.tracker.ui.activity.map.LiveActivityV3
import com.abbidot.tracker.ui.common.map.HomeMapCommonV3 import com.abbidot.tracker.ui.common.map.HomeMapCommonV3
import com.abbidot.tracker.util.Util import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.util.bluetooth.SRBleUtil import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.vm.FamilyViewModel
import com.abbidot.tracker.vm.FencesMapViewModel import com.abbidot.tracker.vm.FencesMapViewModel
import com.abbidot.tracker.vm.MapViewModel import com.abbidot.tracker.vm.MapViewModel
import com.clj.fastble.BleManager import com.clj.fastble.BleManager
import com.hjq.permissions.XXPermissions import com.hjq.permissions.XXPermissions
import com.hjq.permissions.permission.PermissionLists import com.hjq.permissions.permission.PermissionLists
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject import javax.inject.Inject
@@ -63,7 +57,6 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
private val mFencesMapViewModel: FencesMapViewModel by viewModels() private val mFencesMapViewModel: FencesMapViewModel by viewModels()
private val mMapViewModel: MapViewModel by viewModels() private val mMapViewModel: MapViewModel by viewModels()
private val mFamilyViewModel: FamilyViewModel by viewModels()
private lateinit var mLocationManager: LocationManager private lateinit var mLocationManager: LocationManager
@@ -115,7 +108,8 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
mContext!!, mContext!!,
ilHomeMapPetLocation, ilHomeMapPetLocation,
llHomeMapDeviceBatteryLayout, llHomeMapDeviceBatteryLayout,
Utils.DATE_FORMAT_PATTERN_EN11 Utils.DATE_FORMAT_PATTERN_EN11,
true
) { mapLoadOk() } ) { mapLoadOk() }
llHomeMapTopPet.ivTopPetBtnSmall.setImageResource(R.drawable.icon_map_type) llHomeMapTopPet.ivTopPetBtnSmall.setImageResource(R.drawable.icon_map_type)
@@ -211,22 +205,10 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
// mHomeV2Activity.mDataViewModel.getHomeBindPetList(mHomeV2Activity) // mHomeV2Activity.mDataViewModel.getHomeBindPetList(mHomeV2Activity)
getHomeV2Activity()?.apply { getHomeV2Activity()?.apply {
if (mPetList.size > 0) showPetNameAndHead(mSelectPetPosition) if (mPetList.size > 0) showPetNameAndHead(mSelectPetPosition)
mFamilyViewModel.getDeviceInviteInfo(this)
} }
} }
override fun liveDataObserve() { override fun liveDataObserve() {
//获取设备邀请信息
mFamilyViewModel.mInviteInfoLiveData.observe(this) {
dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) {
it.getOrNull()?.apply {
if (deleteArray.isNotEmpty()) showDeleteInviteDialog(deleteArray)
if (inviteArray.isNotEmpty()) showInviteDialog(inviteArray)
}
}
})
}
//获取当前宠物位置和围栏信息 //获取当前宠物位置和围栏信息
mMapViewModel.mMapDeviceLiveData.observe(this) { mMapViewModel.mMapDeviceLiveData.observe(this) {
dealRequestResult(it, object : GetResultCallback { dealRequestResult(it, object : GetResultCallback {
@@ -265,13 +247,15 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
} }
//直播自动结束提示 //直播自动结束提示
XEventBus.observe(this, EventName.LiveAutoEnd) { XEventBus.observe(this, EventName.LiveAutoEnd) {
ViewUtil.instance.showDialog( CommonDialog1(
mContext!!, R.string.txt_live_ended, object : BaseDialog.OnDialogOkListener { mContext!!,
override fun onOkClick(dialog: BaseDialog<*>) { "",
dialog.dismiss() getString(R.string.txt_live_ended),
} false,
}, okTextResId = R.string.txt_sure, cancelTextResId = R.string.txt_cancel 5f,
) Typeface.BOLD,
R.color.data_black_color
).show()
} }
//直播超时 //直播超时
XEventBus.observe(this, EventName.LiveOpenTimeOut) { XEventBus.observe(this, EventName.LiveOpenTimeOut) {
@@ -319,6 +303,15 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
} }
} }
} }
//接收开蓝牙操作,然后搜索连接设备
// XEventBus.observe(this, EventName.BluetoothSwitch) { conState: Int ->
// if (conState == ConState.BLUETOOTH_OFF) {
// //隐藏蓝牙nearby
// mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
// //蓝牙断开就重新获取服务器数据,蓝牙数据上报断开
// updateMapDeviceStatus()
// }
// }
} }
/** /**
@@ -343,7 +336,6 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
) )
mHomeMapCommon.startRefreshUserLocation() mHomeMapCommon.startRefreshUserLocation()
} }
ViewUtil.instance.viewShow(mViewBinding.homeMapLiveBtn)
mMapViewModel.setDeviceStateAndWarningData( mMapViewModel.setDeviceStateAndWarningData(
mContext!!, mContext!!,
getHomeV2Activity()?.getPet(), getHomeV2Activity()?.getPet(),
@@ -359,72 +351,6 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
} }
} }
/**
* 显示被删除邀请的弹窗
*/
private fun showDeleteInviteDialog(deleteArray: MutableList<FamilyBean>) {
lifecycleScope.launch(Dispatchers.IO) {
val myDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DeviceTableName)
myDeviceDb?.apply {
for (deviceDb in myDeviceDb) {
for (item in deleteArray) {
if (deviceDb.deviceId == item.deviceId) {
MyDatabase.deviceDao().delete(deviceDb)
LogUtil.e("删除了邀请的设备")
}
}
}
}
val newDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DeviceTableName)
newDeviceDb?.apply {
LogUtil.e("删去了邀请,还剩${newDeviceDb.size}下个设备")
}
}
CommonDialog1(
mContext!!,
getString(R.string.txt_setting_notification),
getString(R.string.txt_view_access),
false,
okClickListener = object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
getHomeV2Activity()?.apply {
if (mPetList.size == 0) {
noSharePet()
} else {
onChangeClick(0)
}
}
}
}).show()
}
/**
* 显示被邀请通知弹窗
*/
private fun showInviteDialog(inviteArray: MutableList<FamilyBean>) {
for (item in inviteArray) {
val content = String.format(
getString(R.string.txt_invites_you_check), item.userName, item.petName
)
CommonDialog1(
mContext!!,
getString(R.string.txt_setting_notification),
content,
false,
okClickListener = object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
getHomeV2Activity()?.apply {
startActivity(
this, Intent(
this, MyTrackerV2Activity::class.java
)
)
}
}
}).show()
}
}
private val mPermissionsTips = private val mPermissionsTips =
"ABBIDOT APP collects location data,The route and distance between the current location and the device can be calculated." "ABBIDOT APP collects location data,The route and distance between the current location and the device can be calculated."
@@ -537,6 +463,11 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
} }
mCurrentShowPetPos = position mCurrentShowPetPos = position
//隐藏蓝牙nearby
mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE
mViewBinding.ilHomeMapPetLocation.root.visibility = View.GONE
ViewUtil.instance.selectPetDialogShow( ViewUtil.instance.selectPetDialogShow(
mContext, mContext,
mPetList, mPetList,
@@ -553,7 +484,6 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
it.isCloseBattery = false it.isCloseBattery = false
it.canShowBattery = false it.canShowBattery = false
} }
mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
showLoading(true) showLoading(true)
val pet = mPetList[position] val pet = mPetList[position]
//重新设置地图宠物头像 //重新设置地图宠物头像
@@ -571,11 +501,6 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
*/ */
private fun setMapData(mapDeviceBean: MapDeviceBean) { private fun setMapData(mapDeviceBean: MapDeviceBean) {
mapDeviceBean.apply { mapDeviceBean.apply {
//分钟后无上报、没有lte信号或在wifi中隐藏直播按钮
mViewBinding.homeMapLiveBtn.visibility =
if (Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || inWifiZone == ConstantInt.Type1) View.GONE
else View.VISIBLE
setMapDeviceBean(this) setMapDeviceBean(this)
//设置循环查询时间间隔 30秒 //设置循环查询时间间隔 30秒
mMapViewModel.updateMillisInFuture(0.5f) mMapViewModel.updateMillisInFuture(0.5f)
@@ -595,6 +520,11 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
private fun setMapDeviceBean(mapDeviceBean: MapDeviceBean) { private fun setMapDeviceBean(mapDeviceBean: MapDeviceBean) {
mapDeviceBean.apply { mapDeviceBean.apply {
//分钟后无上报、没有lte信号或在wifi中隐藏直播按钮
mViewBinding.homeMapLiveBtn.visibility =
if (Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1) View.GONE
else View.VISIBLE
mViewBinding.ilHomeMapDeviceBatteryLayout.let { mViewBinding.ilHomeMapDeviceBatteryLayout.let {
mMapViewModel.setMapDeviceBattery( mMapViewModel.setMapDeviceBattery(
mContext!!, mapDeviceBean, it.root, it.tvDeviceBatteryInfo, it.ivDeviceCloseBtn mContext!!, mapDeviceBean, it.root, it.tvDeviceBatteryInfo, it.ivDeviceCloseBtn

View File

@@ -51,9 +51,14 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
private var mRippleCirclePercent = 0.0 private var mRippleCirclePercent = 0.0
private var mRippleCircleRadius = 200 private var mRippleCircleRadius = 200
//是否是地图摄像头移动了
private var isMapCameraMove = false private var isMapCameraMove = false
private var mPetAddressTimeFormat = Utils.DATE_FORMAT_PATTERN_EN11 private var mPetAddressTimeFormat = Utils.DATE_FORMAT_PATTERN_EN11
//是否需要反编译地理位置
private var isReverseGeocode = false
companion object { companion object {
@JvmStatic @JvmStatic
fun newInstance( fun newInstance(
@@ -61,11 +66,13 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
locationLayoutViewBinding: LayoutPetLocationInfoBinding, locationLayoutViewBinding: LayoutPetLocationInfoBinding,
deviceBatteryLayout: ViewGroup, deviceBatteryLayout: ViewGroup,
petAddressTimeFormat: String, petAddressTimeFormat: String,
isGeocode: Boolean,
mapLoadOk: () -> Unit mapLoadOk: () -> Unit
) = HomeMapGoogleMapFragmentV3().apply { ) = HomeMapGoogleMapFragmentV3().apply {
mContext = context mContext = context
mDeviceBatteryLayout = deviceBatteryLayout mDeviceBatteryLayout = deviceBatteryLayout
mPetLocationLayoutBinding = locationLayoutViewBinding mPetLocationLayoutBinding = locationLayoutViewBinding
isReverseGeocode = isGeocode
mPetAddressTimeFormat = petAddressTimeFormat mPetAddressTimeFormat = petAddressTimeFormat
mMapLoadOk = mapLoadOk mMapLoadOk = mapLoadOk
} }
@@ -114,6 +121,10 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
} }
} }
setOnCameraMoveListener { setOnCameraMoveListener {
//监听地图放大缩小操作
if (getGoogleMapZoom() != cameraPosition.zoom) {
setGoogleMapZoom(cameraPosition.zoom)
}
isMapCameraMove = true isMapCameraMove = true
setMarkerInfoViewOffset() setMarkerInfoViewOffset()
} }
@@ -154,7 +165,9 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
*/ */
private fun startReverseGeocode() { private fun startReverseGeocode() {
mMapDeviceBean?.apply { mMapDeviceBean?.apply {
if (isReverseGeocode) {
mGeoCoderViewModel.getLatLonAddress(latitude, longitude, false) mGeoCoderViewModel.getLatLonAddress(latitude, longitude, false)
}
setMarkerInfoViewOffset() setMarkerInfoViewOffset()
} }
} }

View File

@@ -168,14 +168,17 @@ class SRBleUtil private constructor() {
gatt: BluetoothGatt, gatt: BluetoothGatt,
status: Int status: Int
) { ) {
LogUtil.e("蓝牙断开${bleDevice.name}${bleDevice.mac}activeDisConnected=$isActiveDisConnected,status=$status") LogUtil.e("蓝牙断开${bleDevice.name}${bleDevice.mac}activeDisConnected=$isActiveDisConnected,status=$status,mContext=$mContext")
notifyDeviceState(bleDevice, ConState.DISCONNECTED)
mContext?.apply { mContext?.apply {
if (isBleEnable(this) && !isActiveDisConnected) { //蓝牙关闭不需要发送断开连接,因为主页已监听蓝牙开关,发送断开连接
if (isBleEnable(this)) {
notifyDeviceState(bleDevice, ConState.DISCONNECTED)
if (!isActiveDisConnected) {
connect(bleDevice) connect(bleDevice)
} }
} }
} }
}
}) })
} }

View File

@@ -23,6 +23,7 @@ import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.util.bluetooth.SRBleUtil import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.widget.TypefaceButton import com.abbidot.tracker.widget.TypefaceButton
import com.abbidot.tracker.widget.TypefaceTextView import com.abbidot.tracker.widget.TypefaceTextView
import com.clj.fastble.BleManager
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class MapViewModel : ViewModel() { class MapViewModel : ViewModel() {
@@ -188,7 +189,6 @@ class MapViewModel : ViewModel() {
setWaringData(context, mapDeviceBean, deviceMsgList, isLive) setWaringData(context, mapDeviceBean, deviceMsgList, isLive)
} }
setDeviceState(context, mapDeviceBean, deviceStateList) setDeviceState(context, mapDeviceBean, deviceStateList)
deviceStateAdapter.notifyItemRangeChanged(0, deviceStateList.size) deviceStateAdapter.notifyItemRangeChanged(0, deviceStateList.size)
deviceMsgAdapter.setData(deviceMsgList) deviceMsgAdapter.setData(deviceMsgList)
deviceMsgAdapter.notifyDataSetChanged() deviceMsgAdapter.notifyDataSetChanged()
@@ -219,7 +219,7 @@ class MapViewModel : ViewModel() {
) { ) {
mapDeviceBean.apply { mapDeviceBean.apply {
tvDeviceMsgView.setBackgroundResource(R.color.device_msg_color1) tvDeviceMsgView.setBackgroundResource(R.color.device_msg_color1)
if (null != petBean && null != SRBleUtil.instance.getConnectMacDevice(petBean.macID)) { if (null != petBean && BleManager.getInstance().isConnected(petBean.macID)) {
if (isCloseMsg && mDeviceMsgType == ConstantInt.Type0) { if (isCloseMsg && mDeviceMsgType == ConstantInt.Type0) {
} else { } else {
@@ -256,8 +256,8 @@ class MapViewModel : ViewModel() {
rootView.visibility = View.GONE rootView.visibility = View.GONE
} }
setDeviceState(context, mapDeviceBean, deviceStateList) setDeviceState(context, mapDeviceBean, deviceStateList)
// deviceStateAdapter.notifyItemRangeChanged(0, deviceStateList.size)
deviceStateAdapter.notifyItemRangeChanged(0, deviceStateList.size) deviceStateAdapter.notifyDataSetChanged()
} }
} }

View File

@@ -21,7 +21,7 @@ import kotlinx.coroutines.launch
*/ */
class UserProfileViewModel : ViewModel() { class UserProfileViewModel : ViewModel() {
val mGetEmailCodeLiveData = MutableLiveData<Result<String>>() val mGetEmailCodeLiveData = MutableLiveData<Result<UserBean>>()
val mValidateCodeLiveData = MutableLiveData<Result<String>>() val mValidateCodeLiveData = MutableLiveData<Result<String>>()
private val mRegisterLiveData = MutableLiveData<Result<String>>() private val mRegisterLiveData = MutableLiveData<Result<String>>()
val mCountryCodeLiveData = MutableLiveData<Result<MutableList<CountryCodeBean>>>() val mCountryCodeLiveData = MutableLiveData<Result<MutableList<CountryCodeBean>>>()

View File

@@ -87,14 +87,6 @@
android:layout_marginEnd="@dimen/dp_12" android:layout_marginEnd="@dimen/dp_12"
android:layoutDirection="rtl" /> android:layoutDirection="rtl" />
<include
android:id="@+id/il_live_v2_bluetooth_find_device"
layout="@layout/layout_bluetooth_find_device"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone" />
<include <include
android:id="@+id/il_live_v3_map_pet_location" android:id="@+id/il_live_v3_map_pet_location"
@@ -133,6 +125,14 @@
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:visibility="gone" /> android:visibility="gone" />
<include
android:id="@+id/il_live_v2_bluetooth_find_device"
layout="@layout/layout_bluetooth_find_device"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone" />
</RelativeLayout> </RelativeLayout>
<include <include

View File

@@ -49,7 +49,7 @@
style="@style/my_TextView_style_v2" style="@style/my_TextView_style_v2"
android:layout_below="@id/il_login_v2_email_address" android:layout_below="@id/il_login_v2_email_address"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
android:text="@string/txt_please_enter_email" android:text="@string/txt_valid_email"
android:textColor="@color/red_color2" android:textColor="@color/red_color2"
android:textSize="@dimen/textSize14" android:textSize="@dimen/textSize14"
android:visibility="gone" android:visibility="gone"

View File

@@ -43,7 +43,7 @@ class Utils {
const val DATE_FORMAT_PATTERN_EN9 = "MMM d, yyyy hh:mm a" const val DATE_FORMAT_PATTERN_EN9 = "MMM d, yyyy hh:mm a"
const val DATE_FORMAT_PATTERN_EN10 = "dd/MM/yyyy HH:mm:ss" const val DATE_FORMAT_PATTERN_EN10 = "dd/MM/yyyy HH:mm:ss"
const val DATE_FORMAT_PATTERN_EN11 = "dd/MM HH:mm" const val DATE_FORMAT_PATTERN_EN11 = "dd/MM HH:mm"
const val DATE_FORMAT_PATTERN_EN12 = "dd/MM HH:mm:ss" const val DATE_FORMAT_PATTERN_EN12 = "HH:mm:ss"
//返回星期几 简写 //返回星期几 简写
const val WEEK_FORMAT_PATTERN = "E" const val WEEK_FORMAT_PATTERN = "E"