Skip to content

Satellite tracker and pass predictor for Android, inspired by Gpredict

Added satellite dots to increase visibility on the map

Arty Bishop89be2dfa4335
diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/mapScreen/MapFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/mapScreen/MapFragment.kt
index 22ae0aa6..7530c950 100644
--- a/app/src/main/java/com/rtbishop/look4sat/presentation/mapScreen/MapFragment.kt
+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/mapScreen/MapFragment.kt
@@ -18,10 +18,9 @@
package com.rtbishop.look4sat.presentation.mapScreen
import android.content.Context
-import android.graphics.Color
-import android.graphics.ColorMatrix
-import android.graphics.ColorMatrixColorFilter
-import android.graphics.Paint
+import android.graphics.*
+import android.graphics.drawable.BitmapDrawable
+import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
@@ -63,6 +62,14 @@ class MapFragment : Fragment(R.layout.fragment_map) {
style = Paint.Style.FILL_AND_STROKE
color = Color.parseColor("#FFE082")
}
+ private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
+ textSize = 28f
+ strokeWidth = 2f
+ style = Paint.Style.FILL
+ color = Color.parseColor("#FFE082")
+ setShadowLayer(3f, 3f, 3f, Color.BLACK)
+ }
+ private val labelRect = Rect()
private lateinit var binding: FragmentMapBinding
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -125,12 +132,8 @@ class MapFragment : Fragment(R.layout.fragment_map) {
posMap.entries.forEach {
Marker(mapView).apply {
setInfoWindow(null)
- textLabelFontSize = 28
- textLabelBackgroundColor = Color.TRANSPARENT
- textLabelForegroundColor =
- ContextCompat.getColor(requireContext(), R.color.accent)
- setTextIcon(it.key.data.name)
setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER)
+ icon = getCustomTextIcon(it.key.data.name)
try {
position = GeoPoint(it.value.latitude, it.value.longitude)
} catch (exception: IllegalArgumentException) {
@@ -148,6 +151,19 @@ class MapFragment : Fragment(R.layout.fragment_map) {
}
}
+ private fun getCustomTextIcon(textLabel: String): Drawable {
+ textPaint.getTextBounds(textLabel, 0, textLabel.length, labelRect)
+ val iconSize = 8f
+ val width = labelRect.width() + iconSize * 2f
+ val height = textPaint.textSize * 3f + iconSize * 2f
+ val bitmap = Bitmap.createBitmap(width.toInt(), height.toInt(), Bitmap.Config.ARGB_8888)
+ Canvas(bitmap).run {
+ drawCircle(width / 2f, height / 2f, iconSize, textPaint)
+ drawText(textLabel, iconSize / 2f, height - iconSize, textPaint)
+ }
+ return BitmapDrawable(binding.mapView.context.resources, bitmap)
+ }
+
private fun handleTrack(satTrack: List<List<GeoPos>>) {
val trackOverlay = FolderOverlay()
satTrack.forEach { track ->
diff --git a/build.gradle b/build.gradle
index f493121f..0e9b3697 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,8 +6,8 @@ buildscript {
}
plugins {
- id "com.android.application" version "7.1.1" apply false
- id "com.android.library" version "7.1.1" apply false
+ id "com.android.application" version '7.1.2' apply false
+ id "com.android.library" version '7.1.2' apply false
id "org.jetbrains.kotlin.android" version "1.6.10" apply false
}