ui: optimize location screen card, remove real location toasts, and add i18n mock disabled prompt on map click
This commit is contained in:
1 parent
a341d862c2
commit
80bba05ecf
4 files changed
+10
-42
No files matched your search
@@ -479,9 +479,6 @@ fun LocationScreen(
|
|||||||
val coordFallback = String.format(Locale.getDefault(), "%.5f, %.5f", wgsLat, wgsLng)
|
val coordFallback = String.format(Locale.getDefault(), "%.5f, %.5f", wgsLat, wgsLng)
|
||||||
locationName = coordFallback
|
locationName = coordFallback
|
||||||
AppPreferences.updateMockLocation(wgsLat, wgsLng, name = coordFallback, isUserManual = isUserManual)
|
AppPreferences.updateMockLocation(wgsLat, wgsLng, name = coordFallback, isUserManual = isUserManual)
|
||||||
if (!AppPreferences.isServiceEnabled) {
|
|
||||||
AppPreferences.updateServiceEnabled(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
val resolvedName = LocationResolver.resolveLocationName(context, wgsLat, wgsLng)
|
val resolvedName = LocationResolver.resolveLocationName(context, wgsLat, wgsLng)
|
||||||
@@ -519,7 +516,6 @@ fun LocationScreen(
|
|||||||
val lm = context.getSystemService(Context.LOCATION_SERVICE) as? LocationManager
|
val lm = context.getSystemService(Context.LOCATION_SERVICE) as? LocationManager
|
||||||
TraceLogger.i("AppUI-Reset", "User clicked 'Reset to Real Location' button. CurrentServiceEnabled=${AppPreferences.isServiceEnabled}, Mock=(${AppPreferences.mockLatitude}, ${AppPreferences.mockLongitude})")
|
TraceLogger.i("AppUI-Reset", "User clicked 'Reset to Real Location' button. CurrentServiceEnabled=${AppPreferences.isServiceEnabled}, Mock=(${AppPreferences.mockLatitude}, ${AppPreferences.mockLongitude})")
|
||||||
if (lm != null) {
|
if (lm != null) {
|
||||||
Toast.makeText(context, "正在获取设备物理定位...", Toast.LENGTH_SHORT).show()
|
|
||||||
fetchRealLocationOnce(lm) { realWgsLat, realWgsLng ->
|
fetchRealLocationOnce(lm) { realWgsLat, realWgsLng ->
|
||||||
TraceLogger.i("AppUI-Reset", "fetchRealLocationOnce SUCCESS: realWgs=($realWgsLat, $realWgsLng)")
|
TraceLogger.i("AppUI-Reset", "fetchRealLocationOnce SUCCESS: realWgs=($realWgsLat, $realWgsLng)")
|
||||||
val gcj = CoordinateConverter.wgs84ToGcj02(realWgsLat, realWgsLng)
|
val gcj = CoordinateConverter.wgs84ToGcj02(realWgsLat, realWgsLng)
|
||||||
@@ -538,7 +534,6 @@ fun LocationScreen(
|
|||||||
AppPreferences.updateMockLocation(realWgsLat, realWgsLng, name = resolved, isUserManual = true)
|
AppPreferences.updateMockLocation(realWgsLat, realWgsLng, name = resolved, isUserManual = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toast.makeText(context, context.getString(R.string.location_located_to_real), Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -580,6 +575,13 @@ fun LocationScreen(
|
|||||||
// 点击即移动位置(无需确认)
|
// 点击即移动位置(无需确认)
|
||||||
val tapOverlay = MapEventsOverlay(object : MapEventsReceiver {
|
val tapOverlay = MapEventsOverlay(object : MapEventsReceiver {
|
||||||
override fun singleTapConfirmedHelper(p: GeoPoint): Boolean {
|
override fun singleTapConfirmedHelper(p: GeoPoint): Boolean {
|
||||||
|
if (!AppPreferences.isServiceEnabled) {
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
context.getString(R.string.location_mock_disabled_prompt),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
// 点击地图位置时,只移动标记,不把点击位置强制作为视图中心
|
// 点击地图位置时,只移动标记,不把点击位置强制作为视图中心
|
||||||
updatePositionAndResolveName(
|
updatePositionAndResolveName(
|
||||||
pointOnMap = p,
|
pointOnMap = p,
|
||||||
@@ -747,43 +749,6 @@ fun LocationScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 虚拟定位总开关控制与状态展示(可直接在地图页一键开启或关闭)
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(top = 4.dp, bottom = 2.dp),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
Surface(
|
|
||||||
shape = RoundedCornerShape(8.dp),
|
|
||||||
color = if (isServiceEnabled) MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.6f) else MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = if (isServiceEnabled) "虚拟定位生效中" else "真机实时定位中",
|
|
||||||
style = MaterialTheme.typography.labelSmall.copy(fontWeight = FontWeight.Bold),
|
|
||||||
color = if (isServiceEnabled) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
modifier = Modifier.padding(horizontal = 8.dp, vertical = 3.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Switch(
|
|
||||||
checked = isServiceEnabled,
|
|
||||||
onCheckedChange = { checked ->
|
|
||||||
AppPreferences.updateServiceEnabled(checked)
|
|
||||||
Toast.makeText(
|
|
||||||
context,
|
|
||||||
if (checked) "虚拟定位已开启" else "已回退真实定位",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
},
|
|
||||||
colors = SwitchDefaults.colors(
|
|
||||||
checkedThumbColor = MaterialTheme.colorScheme.onPrimary,
|
|
||||||
checkedTrackColor = MaterialTheme.colorScheme.primary
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 经纬度信息与复制按钮 (折叠时隐藏)
|
// 经纬度信息与复制按钮 (折叠时隐藏)
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = !isCardCollapsed,
|
visible = !isCardCollapsed,
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
<string name="location_coords_copied">已复制坐标到剪贴板</string>
|
<string name="location_coords_copied">已复制坐标到剪贴板</string>
|
||||||
<string name="location_reset_current">回到原位</string>
|
<string name="location_reset_current">回到原位</string>
|
||||||
<string name="location_located_to_real">已定位到当前真实位置</string>
|
<string name="location_located_to_real">已定位到当前真实位置</string>
|
||||||
|
<string name="location_mock_disabled_prompt">虚拟定位未开启,请先开启虚拟定位</string>
|
||||||
<string name="location_search_back">返回</string>
|
<string name="location_search_back">返回</string>
|
||||||
<string name="location_search_clear">清空</string>
|
<string name="location_search_clear">清空</string>
|
||||||
<string name="location_search_history">搜索历史</string>
|
<string name="location_search_history">搜索历史</string>
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
<string name="location_coords_copied">已复制坐标到剪贴板</string>
|
<string name="location_coords_copied">已复制坐标到剪贴板</string>
|
||||||
<string name="location_reset_current">回到原位</string>
|
<string name="location_reset_current">回到原位</string>
|
||||||
<string name="location_located_to_real">已定位到当前真实位置</string>
|
<string name="location_located_to_real">已定位到当前真实位置</string>
|
||||||
|
<string name="location_mock_disabled_prompt">虚拟定位未开启,请先开启虚拟定位</string>
|
||||||
<string name="location_search_back">返回</string>
|
<string name="location_search_back">返回</string>
|
||||||
<string name="location_search_clear">清空</string>
|
<string name="location_search_clear">清空</string>
|
||||||
<string name="location_search_history">搜索历史</string>
|
<string name="location_search_history">搜索历史</string>
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
<string name="location_coords_copied">Coordinates copied to clipboard</string>
|
<string name="location_coords_copied">Coordinates copied to clipboard</string>
|
||||||
<string name="location_reset_current">Reset to current location</string>
|
<string name="location_reset_current">Reset to current location</string>
|
||||||
<string name="location_located_to_real">Located to current position</string>
|
<string name="location_located_to_real">Located to current position</string>
|
||||||
|
<string name="location_mock_disabled_prompt">Virtual location is not enabled, please enable it first</string>
|
||||||
<string name="location_search_back">Back</string>
|
<string name="location_search_back">Back</string>
|
||||||
<string name="location_search_clear">Clear</string>
|
<string name="location_search_clear">Clear</string>
|
||||||
<string name="location_search_history">Recent Searches</string>
|
<string name="location_search_history">Recent Searches</string>
|
||||||
|
|||||||
Reference in new issue
Block a user