Update README.md
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# LBJ_Console
|
# LBJ_Console
|
||||||
|
|
||||||
LBJ_Console is an Android app designed to receive and display LBJ (Locomotive Bell Jingling) messages via BLE from the [SX1276_Receive_LBJ](https://github.com/undef-i/SX1276_Receive_LBJ) device.
|
LBJ_Console is an Android app designed to receive and display LBJ messages via BLE from the [SX1276_Receive_LBJ](https://github.com/undef-i/SX1276_Receive_LBJ) device.
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package receiver.lbj.ui.screens
|
|||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import receiver.lbj.R
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.Canvas
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
@@ -73,12 +76,14 @@ fun MapScreen(
|
|||||||
osmdroidTileCache = tileCache
|
osmdroidTileCache = tileCache
|
||||||
expirationOverrideDuration = 86400000L
|
expirationOverrideDuration = 86400000L
|
||||||
gpsWaitTime = 0L
|
gpsWaitTime = 0L
|
||||||
tileDownloadThreads = 2
|
tileDownloadThreads = 6
|
||||||
tileFileSystemThreads = 2
|
tileFileSystemThreads = 6
|
||||||
|
tileFileSystemCacheTrimBytes = 1024L * 1024L * 2000
|
||||||
|
tileFileSystemCacheMaxBytes = 1024L * 1024L * 500L
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
onLocationError("地图初始化失败:${e.localizedMessage}")
|
onLocationError("Map initialization failed: ${e.localizedMessage}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,11 +225,15 @@ fun MapScreen(
|
|||||||
ViewGroup.LayoutParams.MATCH_PARENT
|
ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
setTileSource(TileSourceFactory.MAPNIK)
|
setTileSource(TileSourceFactory.MAPNIK)
|
||||||
setMultiTouchControls(true)
|
setMultiTouchControls(true)
|
||||||
zoomController.setVisibility(org.osmdroid.views.CustomZoomButtonsController.Visibility.NEVER)
|
zoomController.setVisibility(org.osmdroid.views.CustomZoomButtonsController.Visibility.NEVER)
|
||||||
isTilesScaledToDpi = true
|
isTilesScaledToDpi = true
|
||||||
|
tilesScaleFactor = ctx.resources.displayMetrics.density * 0.2f
|
||||||
|
setHorizontalMapRepetitionEnabled(false)
|
||||||
|
setVerticalMapRepetitionEnabled(false)
|
||||||
|
isHorizontalMapRepetitionEnabled = false
|
||||||
|
isVerticalMapRepetitionEnabled = false
|
||||||
setUseDataConnection(true)
|
setUseDataConnection(true)
|
||||||
minZoomLevel = 4.0
|
minZoomLevel = 4.0
|
||||||
maxZoomLevel = 18.0
|
maxZoomLevel = 18.0
|
||||||
@@ -249,7 +258,7 @@ fun MapScreen(
|
|||||||
|
|
||||||
val railwayTileSource = XYTileSource(
|
val railwayTileSource = XYTileSource(
|
||||||
"OpenRailwayMap",
|
"OpenRailwayMap",
|
||||||
8, 16,
|
0, 24, // 穷尽所有可能的缩放级别
|
||||||
256,
|
256,
|
||||||
".png",
|
".png",
|
||||||
arrayOf(
|
arrayOf(
|
||||||
@@ -288,7 +297,7 @@ fun MapScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
controller.setZoom(10.0)
|
controller.setZoom(10.0)
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -299,6 +308,27 @@ fun MapScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val myLocationOverlay = MyLocationNewOverlay(locationProvider, this).apply {
|
val myLocationOverlay = MyLocationNewOverlay(locationProvider, this).apply {
|
||||||
|
// 使用我们的自定义人形图标
|
||||||
|
// 使用原生位置/雷达图标
|
||||||
|
val personDrawable = ctx.resources.getDrawable(android.R.drawable.ic_menu_mylocation, ctx.theme)
|
||||||
|
// 设置为黑色
|
||||||
|
personDrawable.setTint(Color.BLACK)
|
||||||
|
|
||||||
|
val bitmap = Bitmap.createBitmap(
|
||||||
|
personDrawable.intrinsicWidth,
|
||||||
|
personDrawable.intrinsicHeight,
|
||||||
|
Bitmap.Config.ARGB_8888
|
||||||
|
)
|
||||||
|
val canvas = Canvas(bitmap)
|
||||||
|
personDrawable.setBounds(0, 0, canvas.width, canvas.height)
|
||||||
|
personDrawable.draw(canvas)
|
||||||
|
|
||||||
|
setPersonIcon(bitmap)
|
||||||
|
// 设置中心对齐
|
||||||
|
setPersonAnchor(0.5f, 0.5f)
|
||||||
|
|
||||||
|
isDrawAccuracyEnabled = false
|
||||||
|
|
||||||
enableMyLocation()
|
enableMyLocation()
|
||||||
|
|
||||||
runOnFirstFix {
|
runOnFirstFix {
|
||||||
@@ -335,21 +365,21 @@ fun MapScreen(
|
|||||||
ScaleBarOverlay(this).apply {
|
ScaleBarOverlay(this).apply {
|
||||||
setCentred(false)
|
setCentred(false)
|
||||||
setScaleBarOffset(5, ctx.resources.displayMetrics.heightPixels - 50)
|
setScaleBarOffset(5, ctx.resources.displayMetrics.heightPixels - 50)
|
||||||
setTextSize(10.0f)
|
setTextSize(12.0f * ctx.resources.displayMetrics.density / 2)
|
||||||
setEnableAdjustLength(true)
|
setEnableAdjustLength(true)
|
||||||
setAlignBottom(true)
|
setAlignBottom(true)
|
||||||
setLineWidth(2.0f)
|
setLineWidth(2.0f)
|
||||||
}.also { overlays.add(it) }
|
}.also { overlays.add(it) }
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
onLocationError("地图组件初始化失败:${e.localizedMessage}")
|
onLocationError("Map component initialization failed: ${e.localizedMessage}")
|
||||||
}
|
}
|
||||||
|
|
||||||
mapViewRef.value = this
|
mapViewRef.value = this
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
onLocationError("地图创建失败:${e.localizedMessage}")
|
onLocationError("Map creation failed: ${e.localizedMessage}")
|
||||||
|
|
||||||
MapView(ctx).apply {
|
MapView(ctx).apply {
|
||||||
layoutParams = ViewGroup.LayoutParams(
|
layoutParams = ViewGroup.LayoutParams(
|
||||||
|
|||||||
13
app/src/main/res/drawable/ic_person.xml
Normal file
13
app/src/main/res/drawable/ic_person.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M12,6m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M12,10L12,10c-2.2,0 -4,1.8 -4,4v6h8v-6C16,11.8 14.2,10 12,10z" />
|
||||||
|
</vector>
|
||||||
Reference in New Issue
Block a user