From 83007612f0e8a329fef07cb0fba497813091ffab Mon Sep 17 00:00:00 2001 From: yezhiqiu <983577727@qq.com> Date: Wed, 3 Dec 2025 14:18:36 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E8=93=9D=E7=89=99=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=BF=9E=E6=8E=A5=202.led=E9=A1=B5=E9=9D=A2=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E4=BF=AE=E6=94=B9=E4=B8=8D=E4=BC=9A=E5=86=8D=E6=AC=A1?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=203.=E4=BC=98=E5=8C=96=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E8=93=9D=E7=89=99=E5=BC=80=E5=90=AF=EF=BC=8C=E7=84=B6=E5=90=8E?= =?UTF-8?q?=E7=AB=8B=E9=A9=AC=E5=85=B3=E9=97=AD=E8=93=9D=E7=89=99=E6=83=85?= =?UTF-8?q?=E5=86=B5=204.=E4=BC=98=E5=8C=96=E7=9B=B4=E6=92=AD=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E7=BC=A9=E6=94=BE=E6=AF=94=E4=BE=8B=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E9=9A=8F=E5=88=B7=E6=96=B0=E8=80=8C=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compile-file-map.properties | 2 +- app/build.gradle | 2 +- .../tracker/retrofit2/INetworkService.kt | 2 +- .../tracker/ui/activity/HomeV2Activity.kt | 158 ++++++++++++++---- .../ui/activity/account/LoginV2Activity.kt | 2 +- .../activity/account/UserProfileActivity.kt | 57 ++++--- .../ui/activity/device/MyTrackerV2Activity.kt | 2 + .../activity/device/set/LedLightActivity.kt | 59 ++++--- .../tracker/ui/activity/map/LiveActivityV3.kt | 62 +++++-- .../ui/activity/pet/PetProfileActivity.kt | 6 +- .../tracker/ui/common/map/HomeMapCommonV3.kt | 2 + .../account/CreateAccountV2OneFragment.kt | 1 + .../ui/fragment/account/EmailValidFragment.kt | 10 +- .../tracker/ui/fragment/map/MapV3Fragment.kt | 132 ++++----------- .../googlemap/HomeMapGoogleMapFragmentV3.kt | 15 +- .../tracker/util/bluetooth/SRBleUtil.kt | 11 +- .../com/abbidot/tracker/vm/MapViewModel.kt | 8 +- .../tracker/vm/UserProfileViewModel.kt | 2 +- app/src/main/res/layout/activity_live_v3.xml | 16 +- app/src/main/res/layout/activity_login_v2.xml | 2 +- .../com/abbidot/baselibrary/util/Utils.kt | 2 +- 21 files changed, 330 insertions(+), 223 deletions(-) diff --git a/FastBleLib/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties b/FastBleLib/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties index 161703c..15bc2f7 100644 --- a/FastBleLib/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +++ b/FastBleLib/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties @@ -1 +1 @@ -#Thu Nov 13 11:09:24 CST 2025 +#Fri Nov 28 15:02:35 CST 2025 diff --git a/app/build.gradle b/app/build.gradle index eebcae9..7e572ef 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,7 +30,7 @@ android { targetSdkVersion 35 versionCode 2101 // versionName "2.1.1" - versionName "2.1.1-Beta4" + versionName "2.1.1-Beta7" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/abbidot/tracker/retrofit2/INetworkService.kt b/app/src/main/java/com/abbidot/tracker/retrofit2/INetworkService.kt index 25f5233..78ce3de 100644 --- a/app/src/main/java/com/abbidot/tracker/retrofit2/INetworkService.kt +++ b/app/src/main/java/com/abbidot/tracker/retrofit2/INetworkService.kt @@ -92,7 +92,7 @@ interface INetworkService { @POST("user/sendEmail") suspend fun getVerificationCode( @Field("email") email: String, @Field("type") type: Int - ): BaseResponse + ): BaseResponse /** * 验证码验证 diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/HomeV2Activity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/HomeV2Activity.kt index f50bd48..3589df4 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/HomeV2Activity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/HomeV2Activity.kt @@ -23,17 +23,22 @@ import com.abbidot.tracker.R import com.abbidot.tracker.adapter.ChangePetListDialogAdapter import com.abbidot.tracker.adapter.ViewPagerAdapter import com.abbidot.tracker.base.BaseActivity +import com.abbidot.tracker.base.BaseDialog import com.abbidot.tracker.bean.BleTrackDeviceBean +import com.abbidot.tracker.bean.FamilyBean import com.abbidot.tracker.bean.PetBean import com.abbidot.tracker.bean.ReceiveDeviceData import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantString import com.abbidot.tracker.constant.GetResultCallback +import com.abbidot.tracker.database.MyDatabase import com.abbidot.tracker.databinding.ActivityHomeV2Binding +import com.abbidot.tracker.dialog.CommonDialog1 import com.abbidot.tracker.dialog.CommonListDialog import com.abbidot.tracker.receiver.BluetoothMonitorReceiver import com.abbidot.tracker.ui.DebugActivity 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.data.ActivityV2Fragment 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.CountDownTimerViewModel import com.abbidot.tracker.vm.DataViewModel +import com.abbidot.tracker.vm.FamilyViewModel import com.abbidot.tracker.vm.LogBleReportViewModel import com.abbidot.tracker.vm.SocketSendMessageViewModel -import com.abbidot.tracker.vm.SubscriptionManageViewModel import com.clj.fastble.BleManager import com.google.android.material.navigation.NavigationBarView import com.hjq.permissions.XXPermissions @@ -70,10 +75,10 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding val mDataViewModel: DataViewModel by viewModels() private val mAutomaticConnectionDeviceViewModel: ConnectionDeviceViewModel by viewModels() - private val mSubscriptionViewModel: SubscriptionManageViewModel by viewModels() private val mLogBleReportViewModel: LogBleReportViewModel by viewModels() private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels() private val mSocketSendMessageViewModel: SocketSendMessageViewModel by viewModels() + private val mFamilyViewModel: FamilyViewModel by viewModels() private var mChangePetDialog: CommonListDialog? = null @@ -88,6 +93,7 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding //是否请求过宠物数据 var isRequestPetData = false + private var mCountdownType = ConstantInt.SpecialType private val mFragments = mutableListOf( ActivityV2Fragment.newInstance(this), @@ -137,44 +143,35 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding it.itemIconTintList = null it.setOnItemSelectedListener(this) } - mPetList = mutableListOf() mChangePetListDialogAdapter = ChangePetListDialogAdapter(mContext, mPetList).apply { setOnChangeClickListener(this@HomeV2Activity) } - //smoothScroll设为false,不显示动画,关闭预加载? true显示过渡动画 mViewBinding.homeV2ViewPager2.setCurrentItem(2, false) setLineShow(2) - //注册监听蓝牙开关广播 - mBleListenerReceiver = BluetoothMonitorReceiver() - val intentFilter = IntentFilter() - intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED) - // 注册广播 - registerReceiver(mBleListenerReceiver, intentFilter) - - checkPermissions() - - mDataViewModel.getHomeBindPetList(this) - - //设置bugly的用户id - 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) + mCountdownType = ConstantInt.Type0 mCountDownTimerViewModel.startCountDown(6) } else { + //注册监听蓝牙开关广播 + mBleListenerReceiver = BluetoothMonitorReceiver() + val intentFilter = IntentFilter() + intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED) + // 注册广播 + registerReceiver(mBleListenerReceiver, intentFilter) + + checkPermissions() + + mDataViewModel.getHomeBindPetList(this) + + //设置bugly的用户id + CrashReport.setUserId(MMKVUtil.getString(MMKVKey.Email)) //预先加载相册,防止上传头像几千张照片加载慢 XXPermissions.with(this).permission(PermissionLists.getReadMediaImagesPermission()) .request { _, allGranted -> @@ -201,8 +198,22 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding //出现闪退,5秒退出APP mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) { - finish() - System.gc() + //自动重启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) + } + } } //退出登录 XEventBus.observe(this, EventName.LogOut) { @@ -215,8 +226,15 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding //接收开蓝牙操作,然后搜索连接设备 XEventBus.observe(this, EventName.BluetoothSwitch) { conState: Int -> if (conState == ConState.BLUETOOTH_ON) { -// mAutomaticConnectionDeviceViewModel.autoConnectBleDevice(mContext) 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 //蓝牙连接断开上传日志 if (ble.mac == macID) { if (ble.conState == ConState.CONNECTED) { + mCountDownTimerViewModel.stopCountDown() //蓝牙连接就去连接socket mBleReportManage.dealBleReportData(macID, null) } else { mLogBleReportViewModel.uploadLog(mContext, macID) + LogUtil.e("15秒监听蓝牙自动连接") + mCountdownType = ConstantInt.Type1 + mCountDownTimerViewModel.startCountDown(15) } } } } + //更新套餐数据 XEventBus.observe(this, EventName.RefreshPackage) { mDataViewModel.getHomeBindPetList(this) @@ -241,6 +264,10 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding XEventBus.observe(this, EventName.RefreshPet) { mDataViewModel.getHomeBindPetList(this) } + //刷新下邀请家人数据 + XEventBus.observe(this, EventName.RefreshHomeList) { + mDataViewModel.getHomeBindPetList(this) + } //删除宠物 XEventBus.observe(this, EventName.DeletePet) { mSelectPetPosition = 0 @@ -308,6 +335,7 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding it.getOrNull()?.apply { setPetData(this) } + mFamilyViewModel.getDeviceInviteInfo(this@HomeV2Activity) } override fun onRequestError(exceptionCode: String?) { @@ -322,6 +350,17 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding 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) { @@ -373,6 +412,65 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding } } + /** + * 显示被删除邀请的弹窗 + */ + private fun showDeleteInviteDialog(deleteArray: MutableList) { + 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) { + 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 */ private fun checkPermissions() { val checkBleOpen = MMKVUtil.getBoolean(MMKVKey.isFirstCheckBleOpen, true) + if (checkBleOpen) MMKVUtil.putBoolean(MMKVKey.isFirstCheckBleOpen, false) Util.checkBluetoothPermissionsEnabled(mContext, { // mAutomaticConnectionDeviceViewModel.autoConnectBleDevice(mContext) }, isCheckBleOpen = checkBleOpen) - if (checkBleOpen) MMKVUtil.putBoolean(MMKVKey.isFirstCheckBleOpen, false) } /** @@ -533,6 +631,8 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding mAutomaticConnectionDeviceViewModel.connectDeviceToMac( this@HomeV2Activity, macID, false ) + mCountdownType = ConstantInt.Type1 + mCountDownTimerViewModel.startCountDown(30) } } } diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/account/LoginV2Activity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/account/LoginV2Activity.kt index 43cc90a..3d6d01a 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/account/LoginV2Activity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/account/LoginV2Activity.kt @@ -189,7 +189,7 @@ class LoginV2Activity : BaseActivity(ActivityLoginV2Bind } } - if (TextUtils.isEmpty(email)) { + if (TextUtils.isEmpty(email) || !Utils.isValidEmail(email)) { isSure = false ViewUtil.instance.setInputViewErrorShow( mContext, ilLoginV2EmailAddress.rlEtInputLayout, tvEmailErrorTipLogin diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/account/UserProfileActivity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/account/UserProfileActivity.kt index 649b7d9..495d828 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/account/UserProfileActivity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/account/UserProfileActivity.kt @@ -108,7 +108,8 @@ class UserProfileActivity : mTakePhotoAndCompressViewModel.registerCropImageActivityResult(this) - mUserViewModel.getCountryCodes(this) +// mUserViewModel.getCountryCodes(this) + mUserViewModel.getUserInfo(this@UserProfileActivity) } override fun onResume() { @@ -124,19 +125,19 @@ class UserProfileActivity : override fun liveDataObserve() { mUserViewModel.apply { //获取国家代码 - mCountryCodeLiveData.observe(this@UserProfileActivity) { - getUserInfo(this@UserProfileActivity) - dealRequestResult(it, object : GetResultCallback { - override fun onResult(any: Any) { - it.getOrNull()?.apply { - mCountryCommon.setCountryCodeData(this) - val countryCode = MMKVUtil.getString(MMKVKey.CountryCode) - val country = mCountryCommon.codeToCountry(countryCode) - mViewBinding.ilUserProfileCountry.etInputContent.setText(country) - } - } - }) - } +// mCountryCodeLiveData.observe(this@UserProfileActivity) { +// getUserInfo(this@UserProfileActivity) +// dealRequestResult(it, object : GetResultCallback { +// override fun onResult(any: Any) { +// it.getOrNull()?.apply { +// mCountryCommon.setCountryCodeData(this) +// val countryCode = MMKVUtil.getString(MMKVKey.CountryCode) +// val country = mCountryCommon.codeToCountry(countryCode) +// mViewBinding.ilUserProfileCountry.etInputContent.setText(country) +// } +// } +// }) +// } //获取用户信息 mUserInfoLiveData.observe(this@UserProfileActivity) { dealRequestResult(it, object : GetResultCallback { @@ -162,7 +163,9 @@ class UserProfileActivity : val data = it.getOrNull() // showToast(R.string.txt_upload_successful) mUploadImageUrl = data!! - mViewBinding.ilUserProfileHeadLayout.ilPetProfileHead.appHeadImage.load(mUploadImageUrl) + mViewBinding.ilUserProfileHeadLayout.ilPetProfileHead.appHeadImage.load( + mUploadImageUrl + ) userProfileSave() } }) @@ -215,7 +218,7 @@ class UserProfileActivity : private fun userProfileSave() { mViewBinding.apply { val name = ilUserProfileNameLayout.etInputContent.text.toString() - val country = ilUserProfileCountry.etInputContent.text.toString() +// val country = ilUserProfileCountry.etInputContent.text.toString() val email = ilUserProfileEmailLayout.etInputContent.text.toString() var isSure = true if (TextUtils.isEmpty(name)) { @@ -224,14 +227,14 @@ class UserProfileActivity : mContext, ilUserProfileNameLayout.rlEtInputLayout, tvUserProfileNameErrorTip ) } - if (TextUtils.isEmpty(country)) { - isSure = false - ViewUtil.instance.setInputViewErrorShow( - mContext, - ilUserProfileCountry.rlEtInputLayout, - tvUserProfileSelectCountryErrorTip - ) - } +// if (TextUtils.isEmpty(country)) { +// isSure = false +// ViewUtil.instance.setInputViewErrorShow( +// mContext, +// ilUserProfileCountry.rlEtInputLayout, +// tvUserProfileSelectCountryErrorTip +// ) +// } if (TextUtils.isEmpty(email) || !Utils.isValidEmail(email)) { isSure = false ViewUtil.instance.setInputViewErrorShow( @@ -241,11 +244,7 @@ class UserProfileActivity : if (!isSure) return mUserViewModel.updateUserInfo( - this@UserProfileActivity, - "", - mUploadImageUrl, - mCountryCommon.getCountryCode(), - name + this@UserProfileActivity, "", mUploadImageUrl, mCountryCommon.getCountryCode(), name ) } } diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/device/MyTrackerV2Activity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/device/MyTrackerV2Activity.kt index de1ef34..553683f 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/device/MyTrackerV2Activity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/device/MyTrackerV2Activity.kt @@ -61,6 +61,8 @@ class MyTrackerV2Activity : override fun getTopBar() = mViewBinding.ilMyTrackerV2TopBar.titleTopBar override fun initData() { + //刷新下邀请家人的数据 + XEventBus.post(EventName.RefreshHomeList) super.initData() setTopBarTitle(R.string.tracker_manage_mine) setLeftBackImage(R.drawable.icon_white_back_svg) diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/device/set/LedLightActivity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/device/set/LedLightActivity.kt index 36818b1..6bcb582 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/device/set/LedLightActivity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/device/set/LedLightActivity.kt @@ -46,6 +46,7 @@ class LedLightActivity : BaseActivity(ActivityLedLightB private var mPetBean: PetBean? = null private var mMapDeviceBean: MapDeviceBean? = null + private var mOldMapDeviceBean: MapDeviceBean? = null private var mBleTrackDeviceBean: BleTrackDeviceBean? = null private lateinit var mLedLightColorAdapter: LedLightColorAdapter private lateinit var mLedModeList: MutableList @@ -76,19 +77,6 @@ class LedLightActivity : BaseActivity(ActivityLedLightB null, 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, _ -> mMapDeviceBean?.apply { @@ -171,7 +159,8 @@ class LedLightActivity : BaseActivity(ActivityLedLightB ledLightBluetoothTips.trbBleConnectState, btnLedLightSetSave, btnLedLightIssue, - ilLedLightIssueLayout.tvCloseIssueBtn + ilLedLightIssueLayout.tvCloseIssueBtn, + mViewBinding.ledLightOpenAndClose.switch ) } @@ -191,6 +180,7 @@ class LedLightActivity : BaseActivity(ActivityLedLightB val data = it.getOrNull() data?.apply { mMapDeviceBean = data + mOldMapDeviceBean = data.copy() setDeviceData(data) } } @@ -260,14 +250,26 @@ class LedLightActivity : BaseActivity(ActivityLedLightB } override fun leftBackOnClick() { + if (null == mMapDeviceBean || null == mOldMapDeviceBean) { + super.leftBackOnClick() + return + } if (isFinishSave) return //是否是蓝牙连接了,修改设备数据返回,同步服务器 if (null != mBleTrackDeviceBean) { - //判断是否有蓝牙连接 - if (BleManager.getInstance().isConnected(mBleTrackDeviceBean!!.bleDevice)) { - finishAndSave(ConstantInt.Type1) - } else { - super.leftBackOnClick() + mMapDeviceBean?.apply { + mOldMapDeviceBean?.let { + if (it == mMapDeviceBean) { + super.leftBackOnClick() + } else { + //判断是否有蓝牙连接 + if (BleManager.getInstance().isConnected(mBleTrackDeviceBean!!.bleDevice)) { + finishAndSave(ConstantInt.Type1) + } else { + super.leftBackOnClick() + } + } + } } } else { super.leftBackOnClick() @@ -278,6 +280,10 @@ class LedLightActivity : BaseActivity(ActivityLedLightB * 保存设置数据 */ private fun finishAndSave(modeType: Int) { + if (null == mMapDeviceBean) { + finish() + return + } mMapDeviceBean?.apply { isFinishSave = true mLedLightViewModel.setLedLight(this@LedLightActivity, this, modeType) @@ -365,6 +371,20 @@ class LedLightActivity : BaseActivity(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?) { mViewBinding.apply { when (v) { @@ -380,6 +400,7 @@ class LedLightActivity : BaseActivity(ActivityLedLightB btnLedLightIssue -> showLedIssue() ilLedLightIssueLayout.tvCloseIssueBtn -> showLedIssue() + ledLightOpenAndClose.switch -> setLedSwitch() } } } diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/map/LiveActivityV3.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/map/LiveActivityV3.kt index 274b2ad..c2514a1 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/map/LiveActivityV3.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/map/LiveActivityV3.kt @@ -134,7 +134,8 @@ class LiveActivityV3 : BaseActivity(ActivityLiveV3Binding mContext, ilLiveV3MapPetLocation, llLiveV3MapDeviceBatteryLayout, - Utils.DATE_FORMAT_PATTERN_EN12 + Utils.DATE_FORMAT_PATTERN_EN12, + isLiveJump ) { mapLoadOk() } ViewUtil.instance.setMapSwitchLocationButtonImage( ivMapLiveV2RefreshBtn, mShowCenterLocation @@ -349,6 +350,19 @@ class LiveActivityV3 : BaseActivity(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 -> if (conState == ConState.DEVICE_NOT_FOUND) { @@ -588,11 +602,16 @@ class LiveActivityV3 : BaseActivity(ActivityLiveV3Binding openNetLive(ConstantInt.Type2) } } else { - if (isLiveJump && isStartLive) { - mPetBean?.apply { - //直播开启后,就去获取直播轨迹 - mMapLiveViewModel.mGetPetLivePointTimeStamp = System.currentTimeMillis() / 1000 - mMapLiveViewModel.getPetLivePoint(deviceId) + if (isLiveJump) { + if (isStartLive) { + mPetBean?.apply { + //直播开启后,就去获取直播轨迹 + mMapLiveViewModel.mGetPetLivePointTimeStamp = + System.currentTimeMillis() / 1000 + mMapLiveViewModel.getPetLivePoint(deviceId) + } + } else { + openNetLive(ConstantInt.Type2) } } } @@ -705,7 +724,7 @@ class LiveActivityV3 : BaseActivity(ActivityLiveV3Binding /** - * 显示选择宠物弹窗 + * 显示选择宠物 */ private fun showPetNameAndHead() { mPetBean?.apply { @@ -752,6 +771,11 @@ class LiveActivityV3 : BaseActivity(ActivityLiveV3Binding ).toString() + mSpeedUnit ilLiveV2OperateLayout.tvLiveV2Speed.text = speedStr + mMapDeviceBean?.let { m -> + isCloseMsg = m.isCloseMsg + isCloseBattery = m.isCloseBattery + canShowBattery = m.canShowBattery + } setMapDeviceBean(this) val isOpen = ledSwitch == ConstantInt.Open ilLiveV2OperateLayout.ilLiveV2DataLightSwitch.cbDeviceLightSwitch.isChecked = isOpen @@ -831,9 +855,10 @@ class LiveActivityV3 : BaseActivity(ActivityLiveV3Binding */ private fun showAndHideFindLayout() { mViewBinding.apply { - ilLiveV3MapPetLocation.root.visibility = View.GONE + llLiveV3MapDeviceBatteryLayout.visibility = View.INVISIBLE val relativeLayout = ivMapLiveV2RefreshBtn.layoutParams as RelativeLayout.LayoutParams ivMapLiveV2RefreshBtn.visibility = View.GONE + ilLiveV3MapPetLocation.root.visibility = View.INVISIBLE if (ilLiveV2BluetoothFindDevice.root.isGone) { //找蓝牙设备布局显示 YoYo.with(Techniques.BounceInUp).duration(800).onStart { @@ -857,16 +882,16 @@ class LiveActivityV3 : BaseActivity(ActivityLiveV3Binding YoYo.with(Techniques.BounceInUp).duration(800).delay(400).onEnd { //蓝牙图标按钮显示动画 ViewUtil.instance.viewShowFadeInAnimation(ivMapLiveV2BluetoothBtn) + ViewUtil.instance.viewShowFadeInAnimation(ilLiveV3MapPetLocation.root) //刷新定位按钮显示动画 ViewUtil.instance.viewShowFadeInAnimation(ivMapLiveV2RefreshBtn) }.playOn(ilLiveV2OperateLayout.root) relativeLayout.removeRule(RelativeLayout.ABOVE) - relativeLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM) + relativeLayout.addRule(RelativeLayout.ABOVE, R.id.il_live_v3_map_pet_location) } root.postDelayed({ - ilLiveV3MapPetLocation.root.visibility = View.VISIBLE mHomeMapCommon.setMarkerInfoViewOffset() }, 1000) } @@ -877,23 +902,24 @@ class LiveActivityV3 : BaseActivity(ActivityLiveV3Binding */ private fun showLiveIssue() { mViewBinding.apply { - ilLiveV3MapPetLocation.root.visibility = View.GONE + llLiveV3MapDeviceBatteryLayout.visibility = View.INVISIBLE if (ilMapLiveV2IssueLayout.root.isGone) { YoYo.with(Techniques.BounceInUp).duration(700).onStart { ilLiveV2OperateLayout.root.visibility = View.GONE + ilLiveV3MapPetLocation.root.visibility = View.INVISIBLE ilMapLiveV2IssueLayout.root.visibility = View.VISIBLE }.playOn(ilMapLiveV2IssueLayout.root) } else { YoYo.with(Techniques.SlideOutDown).duration(600).onEnd { ilMapLiveV2IssueLayout.root.visibility = View.GONE YoYo.with(Techniques.BounceInUp).duration(600).onStart { + ilLiveV3MapPetLocation.root.visibility = View.VISIBLE ilLiveV2OperateLayout.root.visibility = View.VISIBLE }.playOn(ilLiveV2OperateLayout.root) }.playOn(ilMapLiveV2IssueLayout.root) } root.postDelayed({ - ilLiveV3MapPetLocation.root.visibility = View.VISIBLE mHomeMapCommon.setMarkerInfoViewOffset() }, 1000) } @@ -1013,11 +1039,15 @@ class LiveActivityV3 : BaseActivity(ActivityLiveV3Binding ilLiveV2OperateLayout.btnLiveV2Issue -> showLiveIssue() ilMapLiveV2IssueLayout.tvCloseIssueBtn -> showLiveIssue() ilLiveV2BluetoothFindDevice.ivLiveV2FindDeviceSound -> setSound() - ilLiveV3MapDeviceBatteryLayout.ivDeviceCloseBtn -> llLiveV3MapDeviceBatteryLayout.visibility = - View.INVISIBLE + ilLiveV3MapDeviceBatteryLayout.ivDeviceCloseBtn -> { + mMapDeviceBean?.isCloseBattery = true + llLiveV3MapDeviceBatteryLayout.visibility = View.INVISIBLE + } - ilLiveV3MapDeviceMsg.ivDeviceMsgCloseBtn -> ilLiveV3MapDeviceMsg.root.visibility = - View.GONE + ilLiveV3MapDeviceMsg.ivDeviceMsgCloseBtn -> { + mMapDeviceBean?.isCloseMsg = true + ilLiveV3MapDeviceMsg.root.visibility = View.GONE + } } } } diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/pet/PetProfileActivity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/pet/PetProfileActivity.kt index 68f41e4..78e3332 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/pet/PetProfileActivity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/pet/PetProfileActivity.kt @@ -424,13 +424,13 @@ class PetProfileActivity : //接收身高设置页面的值 it.data?.extras?.getFloat(ConstantString.PetHeight)?.apply { 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) { //接收体重设置页面的值 it.data?.extras?.getFloat(ConstantString.PetWeight)?.apply { 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) { mViewBinding.ilPetProfileWeight.etInputContent.setText(any) weight = Util.convertMetricUnits( - any.toFloat(), ConstantInt.Type1,4 + any.toFloat(), ConstantInt.Type1, 4 ) } } diff --git a/app/src/main/java/com/abbidot/tracker/ui/common/map/HomeMapCommonV3.kt b/app/src/main/java/com/abbidot/tracker/ui/common/map/HomeMapCommonV3.kt index ad7e34a..7fe34d4 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/common/map/HomeMapCommonV3.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/common/map/HomeMapCommonV3.kt @@ -31,6 +31,7 @@ class HomeMapCommonV3 @Inject constructor() : BaseMapCommon() { locationLayoutViewBinding: LayoutPetLocationInfoBinding, deviceBatteryLayout: ViewGroup, petAddressTimeFormat: String, + isGeocode: Boolean, mapLoadOk: () -> Unit ): Fragment { return if (AppUtils.isChina(AppUtils.SWITCH_MAP_TYPE)) { @@ -42,6 +43,7 @@ class HomeMapCommonV3 @Inject constructor() : BaseMapCommon() { locationLayoutViewBinding, deviceBatteryLayout, petAddressTimeFormat, + isGeocode, mapLoadOk ) mHomeMapGoogleMapFragment!! diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/account/CreateAccountV2OneFragment.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/account/CreateAccountV2OneFragment.kt index 47c5660..7b18035 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/account/CreateAccountV2OneFragment.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/account/CreateAccountV2OneFragment.kt @@ -168,6 +168,7 @@ class CreateAccountV2OneFragment : BaseFragment( private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels() private val mRegisterViewModel: UserProfileViewModel by viewModels() - private val mResendCodeTime = 5 * 60 + 1 + private val mResendCodeTime = 5 * 60 private var mEmail = "" private var mBtnString = "" private var mEmailCodeType = 0 @@ -57,7 +57,13 @@ open class EmailValidFragment : BaseFragment( fun setEmail(email: String) { mEmail = email //返回上一个页面修改邮箱,再次回到需要更新邮箱显示 - if (isResumed) formatEmail() + if (isResumed) { + mViewBinding.vetForgotPasswordV2EditText.clearContent() + mCountDownTimerViewModel.stopCountDown() + setResendCodeBtnEnabled(false) + mCountDownTimerViewModel.startCountDown(mResendCodeTime.toLong()) + formatEmail() + } } override fun initData() { diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt index e47aceb..080e0c5 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt @@ -2,6 +2,7 @@ package com.abbidot.tracker.ui.fragment.map import android.content.Context import android.content.Intent +import android.graphics.Typeface import android.location.LocationManager import android.provider.Settings import android.view.View @@ -9,7 +10,6 @@ import androidx.core.view.WindowInsetsCompat import androidx.fragment.app.Fragment import androidx.fragment.app.commit import androidx.fragment.app.viewModels -import androidx.lifecycle.lifecycleScope import com.abbidot.baselibrary.constant.ConState import com.abbidot.baselibrary.constant.EventName 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.BleTrackDeviceBean import com.abbidot.tracker.bean.DataBean -import com.abbidot.tracker.bean.FamilyBean import com.abbidot.tracker.bean.MapDeviceBean import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantString import com.abbidot.tracker.constant.GetResultCallback -import com.abbidot.tracker.database.MyDatabase import com.abbidot.tracker.databinding.FragmentMapV3Binding import com.abbidot.tracker.dialog.CommonDialog1 import com.abbidot.tracker.dialog.SelectMapTypeDialog 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.common.map.HomeMapCommonV3 import com.abbidot.tracker.util.Util import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.bluetooth.SRBleUtil -import com.abbidot.tracker.vm.FamilyViewModel import com.abbidot.tracker.vm.FencesMapViewModel import com.abbidot.tracker.vm.MapViewModel import com.clj.fastble.BleManager import com.hjq.permissions.XXPermissions import com.hjq.permissions.permission.PermissionLists import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import javax.inject.Inject @@ -63,7 +57,6 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i private val mFencesMapViewModel: FencesMapViewModel by viewModels() private val mMapViewModel: MapViewModel by viewModels() - private val mFamilyViewModel: FamilyViewModel by viewModels() private lateinit var mLocationManager: LocationManager @@ -115,7 +108,8 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i mContext!!, ilHomeMapPetLocation, llHomeMapDeviceBatteryLayout, - Utils.DATE_FORMAT_PATTERN_EN11 + Utils.DATE_FORMAT_PATTERN_EN11, + true ) { mapLoadOk() } llHomeMapTopPet.ivTopPetBtnSmall.setImageResource(R.drawable.icon_map_type) @@ -211,22 +205,10 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i // mHomeV2Activity.mDataViewModel.getHomeBindPetList(mHomeV2Activity) getHomeV2Activity()?.apply { if (mPetList.size > 0) showPetNameAndHead(mSelectPetPosition) - mFamilyViewModel.getDeviceInviteInfo(this) } } 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) { dealRequestResult(it, object : GetResultCallback { @@ -265,13 +247,15 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i } //直播自动结束提示 XEventBus.observe(this, EventName.LiveAutoEnd) { - ViewUtil.instance.showDialog( - mContext!!, R.string.txt_live_ended, object : BaseDialog.OnDialogOkListener { - override fun onOkClick(dialog: BaseDialog<*>) { - dialog.dismiss() - } - }, okTextResId = R.string.txt_sure, cancelTextResId = R.string.txt_cancel - ) + CommonDialog1( + mContext!!, + "", + getString(R.string.txt_live_ended), + false, + 5f, + Typeface.BOLD, + R.color.data_black_color + ).show() } //直播超时 XEventBus.observe(this, EventName.LiveOpenTimeOut) { @@ -319,6 +303,15 @@ class MapV3Fragment : BaseFragment(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::i ) mHomeMapCommon.startRefreshUserLocation() } - ViewUtil.instance.viewShow(mViewBinding.homeMapLiveBtn) mMapViewModel.setDeviceStateAndWarningData( mContext!!, getHomeV2Activity()?.getPet(), @@ -359,72 +351,6 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i } } - /** - * 显示被删除邀请的弹窗 - */ - private fun showDeleteInviteDialog(deleteArray: MutableList) { - 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) { - 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 = "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::i } mCurrentShowPetPos = position + //隐藏蓝牙nearby + mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE + mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE + mViewBinding.ilHomeMapPetLocation.root.visibility = View.GONE + ViewUtil.instance.selectPetDialogShow( mContext, mPetList, @@ -553,7 +484,6 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i it.isCloseBattery = false it.canShowBattery = false } - mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE showLoading(true) val pet = mPetList[position] //重新设置地图宠物头像 @@ -571,11 +501,6 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i */ private fun setMapData(mapDeviceBean: MapDeviceBean) { 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) //设置循环查询时间间隔 30秒 mMapViewModel.updateMillisInFuture(0.5f) @@ -595,6 +520,11 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i private fun setMapDeviceBean(mapDeviceBean: MapDeviceBean) { 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 { mMapViewModel.setMapDeviceBattery( mContext!!, mapDeviceBean, it.root, it.tvDeviceBatteryInfo, it.ivDeviceCloseBtn diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/map/googlemap/HomeMapGoogleMapFragmentV3.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/map/googlemap/HomeMapGoogleMapFragmentV3.kt index 6e939a1..92977d2 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/map/googlemap/HomeMapGoogleMapFragmentV3.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/map/googlemap/HomeMapGoogleMapFragmentV3.kt @@ -51,9 +51,14 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { private var mRippleCirclePercent = 0.0 private var mRippleCircleRadius = 200 + + //是否是地图摄像头移动了 private var isMapCameraMove = false private var mPetAddressTimeFormat = Utils.DATE_FORMAT_PATTERN_EN11 + //是否需要反编译地理位置 + private var isReverseGeocode = false + companion object { @JvmStatic fun newInstance( @@ -61,11 +66,13 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { locationLayoutViewBinding: LayoutPetLocationInfoBinding, deviceBatteryLayout: ViewGroup, petAddressTimeFormat: String, + isGeocode: Boolean, mapLoadOk: () -> Unit ) = HomeMapGoogleMapFragmentV3().apply { mContext = context mDeviceBatteryLayout = deviceBatteryLayout mPetLocationLayoutBinding = locationLayoutViewBinding + isReverseGeocode = isGeocode mPetAddressTimeFormat = petAddressTimeFormat mMapLoadOk = mapLoadOk } @@ -114,6 +121,10 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { } } setOnCameraMoveListener { + //监听地图放大缩小操作 + if (getGoogleMapZoom() != cameraPosition.zoom) { + setGoogleMapZoom(cameraPosition.zoom) + } isMapCameraMove = true setMarkerInfoViewOffset() } @@ -154,7 +165,9 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { */ private fun startReverseGeocode() { mMapDeviceBean?.apply { - mGeoCoderViewModel.getLatLonAddress(latitude, longitude, false) + if (isReverseGeocode) { + mGeoCoderViewModel.getLatLonAddress(latitude, longitude, false) + } setMarkerInfoViewOffset() } } diff --git a/app/src/main/java/com/abbidot/tracker/util/bluetooth/SRBleUtil.kt b/app/src/main/java/com/abbidot/tracker/util/bluetooth/SRBleUtil.kt index c3150ba..d41b0e2 100644 --- a/app/src/main/java/com/abbidot/tracker/util/bluetooth/SRBleUtil.kt +++ b/app/src/main/java/com/abbidot/tracker/util/bluetooth/SRBleUtil.kt @@ -168,11 +168,14 @@ class SRBleUtil private constructor() { gatt: BluetoothGatt, status: Int ) { - LogUtil.e("蓝牙断开${bleDevice.name},${bleDevice.mac},activeDisConnected=$isActiveDisConnected,status=$status") - notifyDeviceState(bleDevice, ConState.DISCONNECTED) + LogUtil.e("蓝牙断开${bleDevice.name},${bleDevice.mac},activeDisConnected=$isActiveDisConnected,status=$status,mContext=$mContext") mContext?.apply { - if (isBleEnable(this) && !isActiveDisConnected) { - connect(bleDevice) + //蓝牙关闭不需要发送断开连接,因为主页已监听蓝牙开关,发送断开连接 + if (isBleEnable(this)) { + notifyDeviceState(bleDevice, ConState.DISCONNECTED) + if (!isActiveDisConnected) { + connect(bleDevice) + } } } } diff --git a/app/src/main/java/com/abbidot/tracker/vm/MapViewModel.kt b/app/src/main/java/com/abbidot/tracker/vm/MapViewModel.kt index c1b25c2..1e7af02 100644 --- a/app/src/main/java/com/abbidot/tracker/vm/MapViewModel.kt +++ b/app/src/main/java/com/abbidot/tracker/vm/MapViewModel.kt @@ -23,6 +23,7 @@ import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.bluetooth.SRBleUtil import com.abbidot.tracker.widget.TypefaceButton import com.abbidot.tracker.widget.TypefaceTextView +import com.clj.fastble.BleManager import kotlinx.coroutines.launch class MapViewModel : ViewModel() { @@ -188,7 +189,6 @@ class MapViewModel : ViewModel() { setWaringData(context, mapDeviceBean, deviceMsgList, isLive) } setDeviceState(context, mapDeviceBean, deviceStateList) - deviceStateAdapter.notifyItemRangeChanged(0, deviceStateList.size) deviceMsgAdapter.setData(deviceMsgList) deviceMsgAdapter.notifyDataSetChanged() @@ -219,7 +219,7 @@ class MapViewModel : ViewModel() { ) { mapDeviceBean.apply { 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) { } else { @@ -256,8 +256,8 @@ class MapViewModel : ViewModel() { rootView.visibility = View.GONE } setDeviceState(context, mapDeviceBean, deviceStateList) - - deviceStateAdapter.notifyItemRangeChanged(0, deviceStateList.size) +// deviceStateAdapter.notifyItemRangeChanged(0, deviceStateList.size) + deviceStateAdapter.notifyDataSetChanged() } } diff --git a/app/src/main/java/com/abbidot/tracker/vm/UserProfileViewModel.kt b/app/src/main/java/com/abbidot/tracker/vm/UserProfileViewModel.kt index 0399681..287f014 100644 --- a/app/src/main/java/com/abbidot/tracker/vm/UserProfileViewModel.kt +++ b/app/src/main/java/com/abbidot/tracker/vm/UserProfileViewModel.kt @@ -21,7 +21,7 @@ import kotlinx.coroutines.launch */ class UserProfileViewModel : ViewModel() { - val mGetEmailCodeLiveData = MutableLiveData>() + val mGetEmailCodeLiveData = MutableLiveData>() val mValidateCodeLiveData = MutableLiveData>() private val mRegisterLiveData = MutableLiveData>() val mCountryCodeLiveData = MutableLiveData>>() diff --git a/app/src/main/res/layout/activity_live_v3.xml b/app/src/main/res/layout/activity_live_v3.xml index b726390..ab64cef 100644 --- a/app/src/main/res/layout/activity_live_v3.xml +++ b/app/src/main/res/layout/activity_live_v3.xml @@ -87,14 +87,6 @@ android:layout_marginEnd="@dimen/dp_12" android:layoutDirection="rtl" /> - - + +