diff --git a/app/build.gradle b/app/build.gradle index 62467b5..3b397ca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,7 +30,7 @@ android { targetSdkVersion 35 versionCode 2110 // versionName "2.1.10" - versionName "2.1.10-Beta6" + versionName "2.1.10-Beta9" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/abbidot/tracker/bean/MapDeviceBean.kt b/app/src/main/java/com/abbidot/tracker/bean/MapDeviceBean.kt index b917975..ec53834 100644 --- a/app/src/main/java/com/abbidot/tracker/bean/MapDeviceBean.kt +++ b/app/src/main/java/com/abbidot/tracker/bean/MapDeviceBean.kt @@ -36,9 +36,10 @@ data class MapDeviceBean( var startTime: String, var endTime: String, var deviceType: Int, - var canShowBattery: Boolean, - var isCloseBattery: Boolean, - var isCloseMsg: Boolean + var notifyLocationFail: Boolean, + var canShowBattery: Boolean,//是否可以显示电池提示布局 + var isCloseBattery: Boolean,//是否关闭电池提示 + var isCloseMsg: Boolean //是否关闭消息提示 ) : Parcelable { constructor() : this( "", @@ -73,6 +74,7 @@ data class MapDeviceBean( 1, false, false, + false, false ) } 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 4f8276e..5e76ce4 100644 --- a/app/src/main/java/com/abbidot/tracker/retrofit2/INetworkService.kt +++ b/app/src/main/java/com/abbidot/tracker/retrofit2/INetworkService.kt @@ -1409,4 +1409,11 @@ interface INetworkService { @Field("macID") macID: String, @Field("logFileUrl") logFileUrl: String ): BaseResponse + + /** + * 设备一键定位 + */ + @FormUrlEncoded + @POST("map/setupRefreshLocation") + suspend fun setupRefreshLocation(@Field("deviceId") deviceId: String): BaseResponse } \ No newline at end of file diff --git a/app/src/main/java/com/abbidot/tracker/retrofit2/NetworkApi.kt b/app/src/main/java/com/abbidot/tracker/retrofit2/NetworkApi.kt index f569300..ecfffc4 100644 --- a/app/src/main/java/com/abbidot/tracker/retrofit2/NetworkApi.kt +++ b/app/src/main/java/com/abbidot/tracker/retrofit2/NetworkApi.kt @@ -739,6 +739,13 @@ object NetworkApi : BaseNetworkApi(INetworkService.BASE_URL) { service.getMapDeviceStatus(deviceId) } + /** + * 设备一键定位 + */ + suspend fun setupRefreshLocation(deviceId: String) = getResult { + service.setupRefreshLocation(deviceId) + } + /** * 打开关闭直播 */ 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 9cef337..65ee3ba 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 @@ -11,6 +11,7 @@ import android.text.TextUtils import android.view.MenuItem import android.view.View import androidx.activity.viewModels +import androidx.appcompat.widget.AppCompatTextView import androidx.core.view.get import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope @@ -106,6 +107,9 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding //是否检查套餐过期 private var isCheckPackageExpire = true + //是否一键定位 + var isNotifyRefreshLocation = false + private val mFragments = mutableListOf( ActivityV2Fragment.newInstance(this), RouteV2Fragment.newInstance(this), @@ -613,6 +617,33 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding } + /** + * 检测一键定位状态 + */ + fun checkNotifyRefreshLocation(textView: AppCompatTextView) { + textView.let { + if (isNotifyRefreshLocation) { + it.setText(R.string.txt_locating) + it.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0) + } else { + getPet(false)?.let { pet -> + it.text = pet.petName + it.setCompoundDrawablesWithIntrinsicBounds( + 0, 0, R.drawable.icon_gray_down_arrow, 0 + ) + } + } + } + } + + fun refreshLocationBtnState() { + when (mViewBinding.homeV2ViewPager2.currentItem) { + 0 -> (mFragments[0] as ActivityV2Fragment).checkNotifyLocationState() + 1 -> (mFragments[1] as RouteV2Fragment).checkNotifyLocationState() + 3 -> (mFragments[3] as PetV2Fragment).checkNotifyLocationState() + } + } + override fun onCurrentClick() { mChangePetDialog?.dismiss() } 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 8aad477..0ecbfc3 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 @@ -183,6 +183,10 @@ class HomeMapCommonV3 @Inject constructor() : BaseMapCommon() { mHomeMapGoogleMapFragment?.greenRippleCircleAnim() } + fun clearRippleCircleAnim() { + mHomeMapGoogleMapFragment?.clearRippleCircleAnim() + } + fun setMarkerInfoViewOffset() { if (null != mHomeMapBaiduMapFragment) { } else if (null != mHomeMapGoogleMapFragment) { diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/data/ActivityV2Fragment.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/data/ActivityV2Fragment.kt index 583eda2..bc904e1 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/data/ActivityV2Fragment.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/data/ActivityV2Fragment.kt @@ -162,6 +162,13 @@ class ActivityV2Fragment : //其他页面是否选择了宠物 showPetNameAndHead(it.mSelectPetPosition) } + checkNotifyLocationState() + } + } + + fun checkNotifyLocationState() { + getHomeV2Activity()?.apply { + checkNotifyRefreshLocation(mViewBinding.ilHomeActivityTopPet.homeDataPetNameSmall) } } @@ -319,7 +326,11 @@ class ActivityV2Fragment : btnHomeMoreSleep -> goActivityNeedPet(MoreSleepActivity::class.java) - ilHomeActivityTopPet.homeDataPetNameSmall, ilHomeActivityTopPet.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog() + ilHomeActivityTopPet.homeDataPetNameSmall, ilHomeActivityTopPet.homeDataPetHeadSmall.root -> { + getHomeV2Activity()?.let { + if (!it.isNotifyRefreshLocation) it.selectPetDialog() + } + } } } diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/data/RouteV2Fragment.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/data/RouteV2Fragment.kt index 438bf12..e67868f 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/data/RouteV2Fragment.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/data/RouteV2Fragment.kt @@ -154,6 +154,7 @@ class RouteV2Fragment : BaseFragment(FragmentRouteV2Bind } } + private fun initState() { mViewBinding.miHomeRouteAddressView.visibility = View.GONE mHistoryDataMapCommon.clearAllMarker() @@ -228,6 +229,13 @@ class RouteV2Fragment : BaseFragment(FragmentRouteV2Bind if (!isSelectCustomDate) get24HourTime() showPetNameAndHead(mSelectPetPosition) } + checkNotifyLocationState() + } + } + + fun checkNotifyLocationState() { + getHomeV2Activity()?.apply { + checkNotifyRefreshLocation(mViewBinding.ilHomeRoutePetHead.homeDataPetNameSmall) } } @@ -419,9 +427,11 @@ class RouteV2Fragment : BaseFragment(FragmentRouteV2Bind // mContext, NotificationV2Activity::class.java // ) // ) - ilHomeRoutePetHead.homeDataPetNameSmall, ilHomeRoutePetHead.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog( - false - ) + ilHomeRoutePetHead.homeDataPetNameSmall, ilHomeRoutePetHead.homeDataPetHeadSmall.root -> { + getHomeV2Activity()?.let { + if (!it.isNotifyRefreshLocation) it.selectPetDialog(false) + } + } llHomeRouteCalendarFrom -> { getHomeV2Activity()?.getPet()?.let { 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 b66a104..e47153b 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 @@ -1,5 +1,6 @@ package com.abbidot.tracker.ui.fragment.map +import android.animation.AnimatorSet import android.content.Context import android.content.Intent import android.content.res.ColorStateList @@ -100,6 +101,10 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i //是否需要gps坐标转火星坐标 private var needGpsToGCJ02 = true + private var mAnimatorSet: AnimatorSet? = null + + //一键定位开始的时间戳 + private var notifyRefreshLocationTimestamp = 0L companion object { @JvmStatic @@ -150,6 +155,7 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i homeMapRefreshBtn, homeMapBluetoothBtn, homeMapLiveBtn, + ivHomeMapRefreshLocation, llHomeMapTopPet.ivTopPetBtnSmall, llHomeMapTopPet.homeDataPetNameSmall, llHomeMapTopPet.homeDataPetHeadSmall.root, @@ -220,31 +226,31 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i override fun liveDataObserve() { //获取当前宠物位置和围栏信息 - mMapViewModel.mMapDeviceLiveData.observe(this) { - dealRequestResult(it, object : GetResultCallback { - override fun onResult(any: Any) { - val data = it.getOrNull() - data?.apply { - mMapDeviceBean?.let { m -> - data.isCloseMsg = m.isCloseMsg - data.isCloseBattery = m.isCloseBattery - data.canShowBattery = m.canShowBattery + mMapViewModel.apply { + mMapDeviceLiveData.observe(this@MapV3Fragment) { + dealRequestResult(it, object : GetResultCallback { + override fun onResult(any: Any) { + it.getOrNull()?.let { data -> + dealMapData(data) } - mMapDeviceBean = data - setMapData(data) - mMapViewModel.setDeviceStateAndWarningData( - mContext!!, - getHomeV2Activity()?.getPet(), - data, - mViewBinding.ilHomeMapDeviceMsg.root, - mViewBinding.ilHomeMapDeviceMsg.tvDeviceMsgContent, - mViewBinding.ilHomeMapDeviceMsg.ivDeviceMsgCloseBtn, - mDeviceStateList, - mDeviceStateAdapter - ) } - } - }, showLoading = false, isRequestErrorTip = false) + }, showLoading = false, isRequestErrorTip = false) + } + mRefreshLocationLiveData.observe(this@MapV3Fragment) { + dealRequestResult(it, object : GetResultCallback { + override fun onResult(any: Any) { + mMapViewModel.updateMillisInFuture(0.05f) + } + + override fun onErrorCode() { + stopRefreshLocation() + } + + override fun onRequestError(exceptionCode: String?) { + stopRefreshLocation() + } + }) + } } mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) { @@ -317,6 +323,7 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i getHomeV2Activity()?.getPet(false)?.apply { if (trackBle.mac == macID) { if (trackBle.conState == ConState.CONNECTED) { + mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_online) mMapDeviceBean?.let { //连接上蓝牙,关机不显示 if (it.powerSwitch == ConstantInt.Type0) { @@ -345,9 +352,11 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i } //隐藏蓝牙nearby mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE + mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_offline) //蓝牙断开就重新获取服务器数据,蓝牙数据上报断开 updateMapDeviceStatus() } + setRefreshLocationBtnState() } } } @@ -362,6 +371,66 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i // } } + private fun dealMapData(data: MapDeviceBean) { + mMapDeviceBean?.let { m -> + data.notifyLocationFail = m.notifyLocationFail + data.isCloseMsg = m.isCloseMsg + data.isCloseBattery = m.isCloseBattery + data.canShowBattery = m.canShowBattery + } + mMapDeviceBean = data + + getHomeV2Activity()?.apply { + if (isNotifyRefreshLocation) { + if (data.liveFlag == 0) { + stopRefreshLocation() + setMapData(data) + mMapViewModel.setDeviceStateAndWarningData( + mContext, + getPet(), + data, + mViewBinding.ilHomeMapDeviceMsg.root, + mViewBinding.ilHomeMapDeviceMsg.tvDeviceMsgContent, + mViewBinding.ilHomeMapDeviceMsg.ivDeviceMsgCloseBtn, + mDeviceStateList, + mDeviceStateAdapter + ) + } else { + //60秒超时 +// val isRefreshTimeOut = +// (System.currentTimeMillis() - notifyRefreshLocationTimestamp) / 1000 >= 0 +// if (isRefreshTimeOut) { +// stopRefreshLocation() +// mMapDeviceBean!!.notifyLocationFail = true +// mMapDeviceBean!!.isCloseBattery = false +// mMapDeviceBean!!.canShowBattery = true +// mViewBinding.ilHomeMapDeviceBatteryLayout.let { +// mMapViewModel.setMapDeviceBattery( +// mContext, +// mMapDeviceBean!!, +// it.root, +// it.tvDeviceBatteryInfo, +// it.ivDeviceCloseBtn +// ) +// } +// } + } + } else { + setMapData(data) + mMapViewModel.setDeviceStateAndWarningData( + mContext, + getPet(), + data, + mViewBinding.ilHomeMapDeviceMsg.root, + mViewBinding.ilHomeMapDeviceMsg.tvDeviceMsgContent, + mViewBinding.ilHomeMapDeviceMsg.ivDeviceMsgCloseBtn, + mDeviceStateList, + mDeviceStateAdapter + ) + } + } + } + /** * 更新蓝牙上报的数据 */ @@ -517,8 +586,11 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i //隐藏蓝牙nearby mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE mViewBinding.homeMapLiveBtn.visibility = View.GONE + mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_offline) mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE + isCanLive = false + setRefreshLocationBtnState() ViewUtil.instance.selectPetDialogShow( mContext, @@ -586,6 +658,24 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i } } + private fun setRefreshLocationBtnState() { + getHomeV2Activity()?.apply { + getPet(false)?.let { pet -> + mViewBinding.ivHomeMapRefreshLocation.let { + val tintColor = if (SRBleUtil.instance.isMacConnect(pet.macID) || !isCanLive) { + it.setBackgroundResource(R.drawable.shape_light_yellow_circle_bg) + R.color.grey_color + } else { + it.setBackgroundResource(R.drawable.shape_yellow_circle_bg) + R.color.select_color3 + } + it.imageTintList = + ColorStateList.valueOf(ContextCompat.getColor(mContext, tintColor)) + } + } + } + } + private fun setLiveBtnState(canLive: Boolean) { mViewBinding.apply { ViewUtil.instance.viewShow(homeMapLiveBtn) @@ -619,18 +709,21 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i private fun setMapDeviceBean(mapDeviceBean: MapDeviceBean) { mapDeviceBean.apply { val share = MMKVUtil.getInt(MMKVKey.Shared) - mViewBinding.homeMapLiveBtn.visibility = if (share != ConstantInt.NoShare) { - View.GONE - } else { - if (liveFlag == ConstantInt.Type1) View.GONE - else { - //分钟后无上报、没有lte信号或在wifi中隐藏直播按钮 - isCanLive = - !(Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1) - setLiveBtnState(isCanLive) - View.VISIBLE + //分钟后无上报、没有lte信号或在wifi中隐藏直播按钮 + isCanLive = + !(Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1) + mViewBinding.homeMapLiveBtn.visibility = + if (share != ConstantInt.NoShare || deviceType == ConstantInt.Type1) { + View.GONE + } else { + if (liveFlag == ConstantInt.Type1) View.GONE + else { + setLiveBtnState(isCanLive) + View.VISIBLE + } } - } + + setRefreshLocationBtnState() mViewBinding.ilHomeMapDeviceBatteryLayout.let { mMapViewModel.setMapDeviceBattery( @@ -720,6 +813,69 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i } } + /** + * 开始通知一键定位 + */ + private fun notifyRefreshLocation() { + getHomeV2Activity()?.apply { + getPet()?.let { pet -> + if (SRBleUtil.instance.isMacConnect(pet.macID)) { + showToast(R.string.txt_pet_close, gravity = Gravity.CENTER) + } else if (!isCanLive) { + showToast(R.string.txt_locate_works, gravity = Gravity.CENTER) + } else if (!isNotifyRefreshLocation) { + isNotifyRefreshLocation = true + isMoveCamera = true + mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.let { + it.setText(R.string.txt_locating) + it.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0) + } + notifyRefreshLocationTimestamp = System.currentTimeMillis() + mHomeMapCommon.greenRippleCircleAnim() + mViewBinding.ivHomeMapRefreshLocation.let { + it.isEnabled = false + it.imageTintList = ColorStateList.valueOf( + ContextCompat.getColor( + mContext, R.color.grey_color + ) + ) + mAnimatorSet = ViewUtil.instance.viewRotationAnimator(it, true) + } + mMapViewModel.stopGetData() + mMapViewModel.setupRefreshLocation(pet.deviceId) + } + } + } + } + + private fun stopRefreshLocation() { + getHomeV2Activity()?.apply { + if (isNotifyRefreshLocation) { + isNotifyRefreshLocation = false + mHomeMapCommon.clearRippleCircleAnim() + mViewBinding.ivHomeMapRefreshLocation.let { + it.isEnabled = true + it.imageTintList = ColorStateList.valueOf( + ContextCompat.getColor( + mContext, R.color.select_color3 + ) + ) + mAnimatorSet?.cancel() + } + getPet(false)?.let { pet -> + mMapViewModel.updateMillisInFuture(0.35f) + mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.let { + it.text = pet.petName + it.setCompoundDrawablesWithIntrinsicBounds( + 0, 0, R.drawable.icon_gray_down_arrow, 0 + ) + } + } + refreshLocationBtnState() + } + } + } + override fun onClick(v: View?) { if (isLimitClick()) return mViewBinding.apply { @@ -753,9 +909,17 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i goLive(true) } + ivHomeMapRefreshLocation -> notifyRefreshLocation() llHomeMapTopPet.ivTopPetBtnSmall -> showMapTypeDialog() homeMapBluetoothBtn -> checkPermissions(1) - llHomeMapTopPet.homeDataPetNameSmall, llHomeMapTopPet.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog() + llHomeMapTopPet.homeDataPetNameSmall, llHomeMapTopPet.homeDataPetHeadSmall.root -> { + getHomeV2Activity()?.let { + if (!it.isNotifyRefreshLocation) { + getHomeV2Activity()?.selectPetDialog() + } + } + } + ilHomeMapDeviceBatteryLayout.ivDeviceCloseBtn -> { mMapDeviceBean?.isCloseBattery = true llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE 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 d3603ae..373d3dc 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 @@ -229,7 +229,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { mGoogleMap?.let { if (null == mRippleCircle) { mRippleCircle = it.addCircle( - CircleOptions().center(this) + CircleOptions().center(toGCJ02LatLon(this)) .radius(mRippleCircleRadius * mRippleCirclePercent) .strokeWidth(AppUtils.dpToPx(2).toFloat()) .fillColor(ContextCompat.getColor(mContext!!, R.color.black10)) @@ -253,7 +253,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { mRippleCirclePercent = it.animatedValue as Float / 100.0 mRippleCircle?.apply { mPetLatLng?.let { petLatLng -> - center = petLatLng + center = toGCJ02LatLon(petLatLng) radius = mRippleCircleRadius * mRippleCirclePercent } } @@ -261,6 +261,10 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { repeatMode = ValueAnimator.RESTART repeatCount = ValueAnimator.INFINITE } + } else { + mValueAnimator?.apply { + if (!isRunning) start() + } } } @@ -291,7 +295,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { for (i in 0 until trackList.size) { trackList[i].apply { val latLng = LatLng(latitude, longitude) - latLngList.add(latLng) + latLngList.add(toGCJ02LatLon(latLng)) if (i == trackList.size - 1) { // addUserAndPetLine(latLng) refreshPetCurrentLocation(latLng, needMoveCamera = isMoveCamera) @@ -319,6 +323,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { * 直播开始之后,改变绿色波纹动画 */ fun greenRippleCircleAnim() { + if (null == mRippleCircle) addRippleCircle() mRippleCircle?.apply { //一像素对应几米 val pxDis = 2.0.pow(15.5 - getGoogleMapZoom()) @@ -329,8 +334,14 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() { } } + fun clearRippleCircleAnim() { + mValueAnimator?.cancel() + mRippleCircle?.remove() + mRippleCircle = null + } + override fun onDetach() { super.onDetach() - mValueAnimator?.cancel() + clearRippleCircleAnim() } } \ No newline at end of file diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/pet/PetV2Fragment.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/pet/PetV2Fragment.kt index c8dfa8c..612119d 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/pet/PetV2Fragment.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/pet/PetV2Fragment.kt @@ -143,6 +143,13 @@ class PetV2Fragment : BaseFragment(FragmentPetV2Binding::i (mFragments[1] as HomeTrackFragment).getPetTrackerInfoData() } } + checkNotifyLocationState() + } + + fun checkNotifyLocationState() { + getHomeV2Activity()?.apply { + checkNotifyRefreshLocation(mViewBinding.ilHomePetTopBar.homeDataPetNameSmall) + } } override fun onPause() { @@ -207,7 +214,12 @@ class PetV2Fragment : BaseFragment(FragmentPetV2Binding::i override fun onClick(v: View?) { mViewBinding.apply { when (v!!) { - ilHomePetTopBar.homeDataPetNameSmall, ilHomePetTopBar.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog() + ilHomePetTopBar.homeDataPetNameSmall, ilHomePetTopBar.homeDataPetHeadSmall.root -> { + getHomeV2Activity()?.let { + if (!it.isNotifyRefreshLocation) it.selectPetDialog() + } + } + ilHomePetTopBar.ivTopPetBtnSmall -> startActivity( Intent(mContext, NotificationV2Activity::class.java) ) 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 5de5e45..2036ecb 100644 --- a/app/src/main/java/com/abbidot/tracker/vm/MapViewModel.kt +++ b/app/src/main/java/com/abbidot/tracker/vm/MapViewModel.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.launch class MapViewModel : ViewModel() { val mMapDeviceLiveData = MutableLiveData>() + val mRefreshLocationLiveData = MutableLiveData>() private var mCountDownTimer: CountDownTimer? = null //几分钟倒计时(min) @@ -37,6 +38,13 @@ class MapViewModel : ViewModel() { var mDeviceMsgType = ConstantInt.SpecialType + fun setupRefreshLocation(deviceId: String) { + viewModelScope.launch { + val result = NetworkApi.setupRefreshLocation(deviceId) + mRefreshLocationLiveData.value = result + } + } + fun getMapDeviceStatus(deviceId: String, isNeedCountDown: Boolean = true) { viewModelScope.launch { stopGetData() @@ -51,7 +59,7 @@ class MapViewModel : ViewModel() { * 更新刷新时间 */ fun updateMillisInFuture(refreshMin: Float) { - if (refreshMin <= 0 || mRefreshDataMin == refreshMin) return + if (refreshMin <= 0) return mRefreshDataMin = refreshMin countDownGetData(mDeviceId) } @@ -432,7 +440,7 @@ class MapViewModel : ViewModel() { mapDeviceBean: MapDeviceBean, rootView: ViewGroup, batteryText: TypefaceTextView, - closeBtn: AppCompatImageView + closeBtn: AppCompatImageView //可关闭按钮 ) { mapDeviceBean.apply { if (isCloseBattery) return@apply diff --git a/app/src/main/res/drawable-xhdpi/icon_weak_gps_image.png b/app/src/main/res/drawable-xhdpi/icon_weak_gps_image.png new file mode 100644 index 0000000..470edc5 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/icon_weak_gps_image.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon_weak_gps_image.png b/app/src/main/res/drawable-xxhdpi/icon_weak_gps_image.png new file mode 100644 index 0000000..15b2f15 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_weak_gps_image.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/icon_weak_gps_image.png b/app/src/main/res/drawable-xxxhdpi/icon_weak_gps_image.png new file mode 100644 index 0000000..b513c16 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/icon_weak_gps_image.png differ diff --git a/app/src/main/res/drawable/shape_light_yellow_circle_bg.xml b/app/src/main/res/drawable/shape_light_yellow_circle_bg.xml new file mode 100644 index 0000000..179ec38 --- /dev/null +++ b/app/src/main/res/drawable/shape_light_yellow_circle_bg.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_yellow_circle_bg.xml b/app/src/main/res/drawable/shape_yellow_circle_bg.xml index 430ea6a..10ce690 100644 --- a/app/src/main/res/drawable/shape_yellow_circle_bg.xml +++ b/app/src/main/res/drawable/shape_yellow_circle_bg.xml @@ -1,6 +1,6 @@ - + @@ -12,4 +12,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_map_v3.xml b/app/src/main/res/layout/fragment_map_v3.xml index eaaddc4..2e3b536 100644 --- a/app/src/main/res/layout/fragment_map_v3.xml +++ b/app/src/main/res/layout/fragment_map_v3.xml @@ -66,30 +66,46 @@ android:visibility="invisible" /> + android:layout_marginBottom="@dimen/dp_18" + android:tint="@color/grey_color" /> + + + + + android:paddingVertical="@dimen/dp_16" + android:visibility="gone"> #26A8FF #077B4A #00C478 + #F9FFE8 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4482ee5..347b99b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1058,7 +1058,6 @@ Tracker Offline. Unable to proceed. Live stream in progress. Settings unavailable. Operation failed. Please try again. - /day Renewal: $%s/%s day on %s /day x%s @@ -1069,5 +1068,8 @@ (Renew at $%s/%s years thereafter) (Renew at $%s/%s months thereafter) Tone + Locate works on cellular only + Pet is close, try Radar + \ No newline at end of file