1.优化一键定位按钮不同状态颜色
2.谷歌地图用户定位位置图标国内外同时放开 3.优化圆形和矩形围栏按钮点击范围
This commit is contained in:
4
.idea/deploymentTargetSelector.xml
generated
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-10-09T01:39:35.620630500Z">
|
<DropdownSelection timestamp="2026-04-01T06:06:01.472811800Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="LocalEmulator" identifier="path=H:\androidAvd\.android\avd\Pixel_9_Pro.avd" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=3A040DLJH000R0" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ android {
|
|||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 35
|
targetSdkVersion 35
|
||||||
versionCode 2112
|
versionCode 2112
|
||||||
// versionName "2.1.12"
|
versionName "2.1.12"
|
||||||
versionName "2.1.12-Beta2"
|
// versionName "2.1.12-Beta4"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -671,9 +671,12 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
|||||||
getHomeV2Activity()?.apply {
|
getHomeV2Activity()?.apply {
|
||||||
getPet(false)?.let { pet ->
|
getPet(false)?.let { pet ->
|
||||||
mViewBinding.ivHomeMapRefreshLocation.let {
|
mViewBinding.ivHomeMapRefreshLocation.let {
|
||||||
val tintColor = if (SRBleUtil.instance.isMacConnect(pet.macID) || !isCanLive) {
|
val tintColor = if (SRBleUtil.instance.isMacConnect(pet.macID)) {
|
||||||
it.setBackgroundResource(R.drawable.shape_light_yellow_circle_bg)
|
it.setBackgroundResource(R.drawable.shape_yellow_circle_bg)
|
||||||
R.color.grey_color
|
R.color.select_color3
|
||||||
|
} else if (!isCanLive) {
|
||||||
|
it.setBackgroundResource(R.drawable.shape_white_circle_bg)
|
||||||
|
R.color.grey_color_91
|
||||||
} else {
|
} else {
|
||||||
it.setBackgroundResource(R.drawable.shape_yellow_circle_bg)
|
it.setBackgroundResource(R.drawable.shape_yellow_circle_bg)
|
||||||
R.color.select_color3
|
R.color.select_color3
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ abstract class BaseGoogleMapFragment :
|
|||||||
|
|
||||||
//指定地图的初始照相机位置(指定 null 以使用 默认摄像机位置)
|
//指定地图的初始照相机位置(指定 null 以使用 默认摄像机位置)
|
||||||
val options = GoogleMapOptions().apply {
|
val options = GoogleMapOptions().apply {
|
||||||
|
// val options = GoogleMapOptions().liteMode(true)
|
||||||
//默认华盛顿经纬度
|
//默认华盛顿经纬度
|
||||||
val lat = MMKVUtil.getDouble(MMKVKey.MapShowDefaultLat, 38.913611)
|
val lat = MMKVUtil.getDouble(MMKVKey.MapShowDefaultLat, 38.913611)
|
||||||
val lon = MMKVUtil.getDouble(MMKVKey.MapShowDefaultLon, -77.013222)
|
val lon = MMKVUtil.getDouble(MMKVKey.MapShowDefaultLon, -77.013222)
|
||||||
@@ -388,22 +389,23 @@ abstract class BaseGoogleMapFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
mGoogleMap?.apply {
|
|
||||||
if (!isMyLocationEnabled) {
|
|
||||||
//检测权限,开启用户的当前位置https://developers.google.cn/maps/documentation/android-sdk/location?hl=zh-cn
|
|
||||||
if (ActivityCompat.checkSelfPermission(
|
|
||||||
mContext!!, Manifest.permission.ACCESS_FINE_LOCATION
|
|
||||||
) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
|
|
||||||
mContext!!, Manifest.permission.ACCESS_COARSE_LOCATION
|
|
||||||
) == PackageManager.PERMISSION_GRANTED
|
|
||||||
) {
|
|
||||||
//启用“我的位置”图层。
|
|
||||||
isMyLocationEnabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// else {
|
||||||
|
// mGoogleMap?.apply {
|
||||||
|
// if (!isMyLocationEnabled) {
|
||||||
|
// //检测权限,开启用户的当前位置https://developers.google.cn/maps/documentation/android-sdk/location?hl=zh-cn
|
||||||
|
// if (ActivityCompat.checkSelfPermission(
|
||||||
|
// mContext!!, Manifest.permission.ACCESS_FINE_LOCATION
|
||||||
|
// ) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
|
||||||
|
// mContext!!, Manifest.permission.ACCESS_COARSE_LOCATION
|
||||||
|
// ) == PackageManager.PERMISSION_GRANTED
|
||||||
|
// ) {
|
||||||
|
// //启用“我的位置”图层。
|
||||||
|
// isMyLocationEnabled = true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -914,8 +916,6 @@ abstract class BaseGoogleMapFragment :
|
|||||||
LogUtil.e("谷歌地图加载好了")
|
LogUtil.e("谷歌地图加载好了")
|
||||||
mGoogleMap = googleMap
|
mGoogleMap = googleMap
|
||||||
|
|
||||||
// val options = GoogleMapOptions().liteMode(true)
|
|
||||||
|
|
||||||
isMapLoadOk = true
|
isMapLoadOk = true
|
||||||
|
|
||||||
// googleMap.uiSettings.apply {
|
// googleMap.uiSettings.apply {
|
||||||
@@ -934,15 +934,15 @@ abstract class BaseGoogleMapFragment :
|
|||||||
//显示实时交通信息
|
//显示实时交通信息
|
||||||
// isTrafficEnabled = true
|
// isTrafficEnabled = true
|
||||||
//检测权限,开启用户的当前位置https://developers.google.cn/maps/documentation/android-sdk/location?hl=zh-cn
|
//检测权限,开启用户的当前位置https://developers.google.cn/maps/documentation/android-sdk/location?hl=zh-cn
|
||||||
// if (ActivityCompat.checkSelfPermission(
|
if (ActivityCompat.checkSelfPermission(
|
||||||
// mContext!!, Manifest.permission.ACCESS_FINE_LOCATION
|
mContext!!, Manifest.permission.ACCESS_FINE_LOCATION
|
||||||
// ) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
|
) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
|
||||||
// mContext!!, Manifest.permission.ACCESS_COARSE_LOCATION
|
mContext!!, Manifest.permission.ACCESS_COARSE_LOCATION
|
||||||
// ) == PackageManager.PERMISSION_GRANTED
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
// ) {
|
) {
|
||||||
// //启用“我的位置”图层。
|
//启用“我的位置”图层。
|
||||||
// isMyLocationEnabled = true
|
isMyLocationEnabled = true
|
||||||
// }
|
}
|
||||||
uiSettings.let {
|
uiSettings.let {
|
||||||
//禁止显示“我的位置”按钮。
|
//禁止显示“我的位置”按钮。
|
||||||
it.isMyLocationButtonEnabled = false
|
it.isMyLocationButtonEnabled = false
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import com.easysocket.config.EasySocketOptions
|
|||||||
import com.easysocket.entity.OriginReadData
|
import com.easysocket.entity.OriginReadData
|
||||||
import com.easysocket.entity.SocketAddress
|
import com.easysocket.entity.SocketAddress
|
||||||
import com.easysocket.interfaces.conn.ISocketActionListener
|
import com.easysocket.interfaces.conn.ISocketActionListener
|
||||||
|
import java.util.Timer
|
||||||
|
import kotlin.concurrent.timerTask
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +23,7 @@ import com.easysocket.interfaces.conn.ISocketActionListener
|
|||||||
class SocketUtilManageV2 {
|
class SocketUtilManageV2 {
|
||||||
|
|
||||||
private var mNeedSendMessage = byteArrayOf()
|
private var mNeedSendMessage = byteArrayOf()
|
||||||
|
private val mTimer = Timer()
|
||||||
private var mMac = ""
|
private var mMac = ""
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@@ -31,7 +34,8 @@ class SocketUtilManageV2 {
|
|||||||
val data4 = SRBleCmdUtil.instance.byteToInt(data[4])
|
val data4 = SRBleCmdUtil.instance.byteToInt(data[4])
|
||||||
val ip = "$data1.$data2.$data3.$data4"
|
val ip = "$data1.$data2.$data3.$data4"
|
||||||
val port = SRBleCmdUtil.instance.byte2ArrayToInt(data.sliceArray(5..6))
|
val port = SRBleCmdUtil.instance.byte2ArrayToInt(data.sliceArray(5..6))
|
||||||
LogUtil.e("$ip:$port")
|
val socketAddress = "$ip:$port"
|
||||||
|
LogUtil.e(socketAddress)
|
||||||
mMac = mac
|
mMac = mac
|
||||||
mNeedSendMessage = data.sliceArray(8..data.size - 2)
|
mNeedSendMessage = data.sliceArray(8..data.size - 2)
|
||||||
initEasySocket(context, ip, port)
|
initEasySocket(context, ip, port)
|
||||||
@@ -49,13 +53,17 @@ class SocketUtilManageV2 {
|
|||||||
.build()
|
.build()
|
||||||
//初始化EasySocket
|
//初始化EasySocket
|
||||||
EasySocket.getInstance().createConnection(options, context).setDebug(AppUtils.isDebug())
|
EasySocket.getInstance().createConnection(options, context).setDebug(AppUtils.isDebug())
|
||||||
|
// EasySocket.getInstance().createSpecifyConnection(options, context)
|
||||||
|
|
||||||
//监听socket相关行为
|
//监听socket相关行为
|
||||||
EasySocket.getInstance().subscribeSocketAction(object : ISocketActionListener {
|
EasySocket.getInstance().subscribeSocketAction(object : ISocketActionListener {
|
||||||
override fun onSocketConnSuccess(socketAddress: SocketAddress?) {
|
override fun onSocketConnSuccess(socketAddress: SocketAddress?) {
|
||||||
LogUtil.e("socket连接成功,${HexUtil.formatHexString(mNeedSendMessage, true)}")
|
LogUtil.e("socket连接成功")
|
||||||
//发送
|
//发送
|
||||||
EasySocket.getInstance().upMessage(mNeedSendMessage)
|
mTimer.schedule(timerTask {
|
||||||
|
LogUtil.e("发送")
|
||||||
|
EasySocket.getInstance().upMessage(mNeedSendMessage)
|
||||||
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSocketConnFail(socketAddress: SocketAddress?, isNeedReconnect: Boolean) {
|
override fun onSocketConnFail(socketAddress: SocketAddress?, isNeedReconnect: Boolean) {
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ class FencesCircleView : View {
|
|||||||
val x = event.x
|
val x = event.x
|
||||||
val y = event.y
|
val y = event.y
|
||||||
mZoomBitmap?.apply {
|
mZoomBitmap?.apply {
|
||||||
if (x in mLineEndX - width / 2..mLineEndX + width / 2 && y in mLineEndY - height / 2..mLineEndY + height / 2) {
|
if (x in mLineEndX - width..mLineEndX + width && y in mLineEndY - height..mLineEndY + height) {
|
||||||
isScale = true
|
isScale = true
|
||||||
mOldX = x
|
mOldX = x
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -341,7 +341,8 @@ class FencesRectView : View {
|
|||||||
locationDrawableRes: Int = 0,
|
locationDrawableRes: Int = 0,
|
||||||
zoomDrawableRes: Int = 0,
|
zoomDrawableRes: Int = 0,
|
||||||
dotDrawableRes: Int = 0,
|
dotDrawableRes: Int = 0,
|
||||||
rotateDrawableRes: Int = 0,disTextColorRes: Int = 0
|
rotateDrawableRes: Int = 0,
|
||||||
|
disTextColorRes: Int = 0
|
||||||
) {
|
) {
|
||||||
var isRefresh = false
|
var isRefresh = false
|
||||||
if (dashedColorRes > 0) {
|
if (dashedColorRes > 0) {
|
||||||
@@ -563,14 +564,20 @@ class FencesRectView : View {
|
|||||||
return floatArrayOf((b).toFloat(), (a).toFloat())
|
return floatArrayOf((b).toFloat(), (a).toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private fun isClick(
|
||||||
* 是否点击按下了旋转,按照移动了坐标轴原点(mCentreX,mCentreY)计算初始坐标
|
bitmap: Bitmap,
|
||||||
*/
|
clickX: Float,
|
||||||
private fun isClickRotate(clickX: Float, clickY: Float, rotate: Double): Boolean {
|
clickY: Float,
|
||||||
var x1 = -(mRectWidth / 2 - mRotateBitmap!!.width / 2)
|
xX1: Float,
|
||||||
var x2 = (mRectWidth / 2 - mRotateBitmap!!.width / 2)
|
xX2: Float,
|
||||||
var y1 = -(mRectHeight / 2 + mRotateBitmap!!.height + mRotateBitmap!!.width)
|
yY1: Float,
|
||||||
var y2 = -(mRectHeight / 2 - mRotateBitmap!!.height)
|
yY2: Float,
|
||||||
|
rotate: Double
|
||||||
|
): Boolean {
|
||||||
|
var x1 = xX1
|
||||||
|
var x2 = xX2
|
||||||
|
var y1 = yY1
|
||||||
|
var y2 = yY2
|
||||||
val minX = getRotateXY(x1, y1, rotate)
|
val minX = getRotateXY(x1, y1, rotate)
|
||||||
val maxX = getRotateXY(x2, y2, rotate)
|
val maxX = getRotateXY(x2, y2, rotate)
|
||||||
x1 = minX[0]
|
x1 = minX[0]
|
||||||
@@ -586,61 +593,48 @@ class FencesRectView : View {
|
|||||||
y2 = minX[1]
|
y2 = minX[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理旋转到某个角度时,旋转图片按钮会超出坐标范围内,不在可点击坐标范围内,把可点击的坐标范围扩大
|
//处理旋转到某个角度时,图片按钮会超出坐标范围内,不在可点击坐标范围内,把可点击的坐标范围扩大
|
||||||
if (abs(x2 - x1) < mRotateBitmap!!.height) {
|
if (abs(x2 - x1) < bitmap.height) {
|
||||||
if (x2 > 0) {
|
if (x2 > 0) {
|
||||||
x2 += mRotateBitmap!!.height
|
x2 += bitmap.height
|
||||||
} else {
|
} else {
|
||||||
x1 -= mRotateBitmap!!.height
|
x1 -= bitmap.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (abs(y2 - y1) < mRotateBitmap!!.height) {
|
if (abs(y2 - y1) < bitmap.height) {
|
||||||
if (y2 > 0) {
|
if (y2 > 0) {
|
||||||
y2 += mRotateBitmap!!.height
|
y2 += bitmap.height
|
||||||
} else {
|
} else {
|
||||||
y1 -= mRotateBitmap!!.height
|
y1 -= bitmap.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val transformX = clickX - mCentreX
|
val transformX = clickX - mCentreX
|
||||||
val transformY = clickY - mCentreY
|
val transformY = clickY - mCentreY
|
||||||
|
|
||||||
if (transformX in x1..x2 && transformY in y1..y2) {
|
return transformX in x1..x2 && transformY in y1..y2
|
||||||
return true
|
}
|
||||||
}
|
|
||||||
return false
|
/**
|
||||||
|
* 是否点击按下了旋转,按照移动了坐标轴原点(mCentreX,mCentreY)计算初始坐标
|
||||||
|
*/
|
||||||
|
private fun isClickRotate(clickX: Float, clickY: Float, rotate: Double): Boolean {
|
||||||
|
val x1 = -(mRectWidth / 2 - mRotateBitmap!!.width / 2)
|
||||||
|
val x2 = (mRectWidth / 2 - mRotateBitmap!!.width / 2)
|
||||||
|
val y1 = -(mRectHeight / 2 + mRotateBitmap!!.height + mRotateBitmap!!.width)
|
||||||
|
val y2 = -(mRectHeight / 2 - mRotateBitmap!!.height)
|
||||||
|
return isClick(mRotateBitmap!!, clickX, clickY, x1, x2, y1, y2, rotate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否点击按下了放大缩小,按照移动了坐标轴原点(mCentreX,mCentreY)计算初始坐标
|
* 是否点击按下了放大缩小,按照移动了坐标轴原点(mCentreX,mCentreY)计算初始坐标
|
||||||
*/
|
*/
|
||||||
private fun isClickScale(clickX: Float, clickY: Float, rotate: Double): Boolean {
|
private fun isClickScale(clickX: Float, clickY: Float, rotate: Double): Boolean {
|
||||||
var x1 = (mRectWidth / 2 - mZoomBitmap!!.width)
|
val x1 = (mRectWidth / 2 - mZoomBitmap!!.width / 2)
|
||||||
var x2 = (mRectWidth / 2 + mZoomBitmap!!.width)
|
val x2 = (mRectWidth / 2 + mZoomBitmap!!.width / 2)
|
||||||
var y1 = (mRectHeight / 2 - mRotateBitmap!!.height)
|
val y1 = (mRectHeight / 2 - mZoomBitmap!!.height)
|
||||||
var y2 = (mRectHeight / 2 + mRotateBitmap!!.height)
|
val y2 = (mRectHeight / 2 + mZoomBitmap!!.height)
|
||||||
val minX = getRotateXY(x1, y1, rotate)
|
return isClick(mZoomBitmap!!, clickX, clickY, x1, x2, y1, y2, rotate)
|
||||||
val maxX = getRotateXY(x2, y2, rotate)
|
|
||||||
x1 = minX[0]
|
|
||||||
x2 = maxX[0]
|
|
||||||
if (minX[0] > maxX[0]) {
|
|
||||||
x1 = maxX[0]
|
|
||||||
x2 = minX[0]
|
|
||||||
}
|
|
||||||
y1 = minX[1]
|
|
||||||
y2 = maxX[1]
|
|
||||||
if (minX[1] > maxX[1]) {
|
|
||||||
y1 = maxX[1]
|
|
||||||
y2 = minX[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
val transformX = clickX - mCentreX
|
|
||||||
val transformY = clickY - mCentreY
|
|
||||||
|
|
||||||
if (transformX in x1..x2 && transformY in y1..y2) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -376,4 +376,5 @@
|
|||||||
<color name="line_stroke_color">#077B4A</color>
|
<color name="line_stroke_color">#077B4A</color>
|
||||||
<color name="rote_line_color">#00C478</color>
|
<color name="rote_line_color">#00C478</color>
|
||||||
<color name="light_yellow_color">#F9FFE8</color>
|
<color name="light_yellow_color">#F9FFE8</color>
|
||||||
|
<color name="grey_color_91">#B0B0B0</color>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user