diff --git a/app/src/main/java/com/lzxnone/openloc/ui/screens/location/LocationScreen.kt b/app/src/main/java/com/lzxnone/openloc/ui/screens/location/LocationScreen.kt index 34f2617..3301bd8 100644 --- a/app/src/main/java/com/lzxnone/openloc/ui/screens/location/LocationScreen.kt +++ b/app/src/main/java/com/lzxnone/openloc/ui/screens/location/LocationScreen.kt @@ -479,9 +479,6 @@ fun LocationScreen( val coordFallback = String.format(Locale.getDefault(), "%.5f, %.5f", wgsLat, wgsLng) locationName = coordFallback AppPreferences.updateMockLocation(wgsLat, wgsLng, name = coordFallback, isUserManual = isUserManual) - if (!AppPreferences.isServiceEnabled) { - AppPreferences.updateServiceEnabled(true) - } coroutineScope.launch { val resolvedName = LocationResolver.resolveLocationName(context, wgsLat, wgsLng) @@ -519,7 +516,6 @@ fun LocationScreen( 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})") if (lm != null) { - Toast.makeText(context, "正在获取设备物理定位...", Toast.LENGTH_SHORT).show() fetchRealLocationOnce(lm) { realWgsLat, realWgsLng -> TraceLogger.i("AppUI-Reset", "fetchRealLocationOnce SUCCESS: realWgs=($realWgsLat, $realWgsLng)") val gcj = CoordinateConverter.wgs84ToGcj02(realWgsLat, realWgsLng) @@ -538,7 +534,6 @@ fun LocationScreen( 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 { 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( 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( visible = !isCardCollapsed, diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index d1b1227..672cdda 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -54,6 +54,7 @@ 已复制坐标到剪贴板 回到原位 已定位到当前真实位置 + 虚拟定位未开启,请先开启虚拟定位 返回 清空 搜索历史 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index d1b1227..672cdda 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -54,6 +54,7 @@ 已复制坐标到剪贴板 回到原位 已定位到当前真实位置 + 虚拟定位未开启,请先开启虚拟定位 返回 清空 搜索历史 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 33d6220..483f92b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -54,6 +54,7 @@ Coordinates copied to clipboard Reset to current location Located to current position + Virtual location is not enabled, please enable it first Back Clear Recent Searches