Minor fixes to resources and UI

This commit is contained in:
Arty Bishop committed 2020-11-27 23:34:04 +00:00
1 parent e9eba47429
commit 62f8a4a534
10 files changed
+40 -36

No files matched your search

@@ -64,7 +64,7 @@ class MapFragment : Fragment(R.layout.fragment_map) {
trackPaint = Paint().apply {
strokeWidth = 2f
style = Paint.Style.STROKE
color = ContextCompat.getColor(requireContext(), R.color.satTrack)
color = Color.RED
strokeCap = Paint.Cap.ROUND
strokeJoin = Paint.Join.ROUND
isAntiAlias = true
@@ -112,11 +112,9 @@ class MapFragment : Fragment(R.layout.fragment_map) {
}
})
viewModel.getSelectedPass().observe(viewLifecycleOwner, { satPass ->
satPass?.let {
selectedSat = satPass
setSelectedSatDetails(satPass)
scrollToSat(satPass)
}
selectedSat = satPass
setSelectedSatDetails(satPass)
scrollToSat(satPass)
})
viewModel.getSatMarkers().observe(viewLifecycleOwner, {
setMarkers(it)
@@ -223,7 +221,7 @@ class MapFragment : Fragment(R.layout.fragment_map) {
}
private fun getColorFilter(): ColorMatrixColorFilter {
val targetColor = ContextCompat.getColor(requireContext(), R.color.satTrack)
val targetColor = Color.RED
val newR = Color.red(targetColor) / 255f
val newG = Color.green(targetColor) / 255f
val newB = Color.blue(targetColor) / 255f
@@ -9,6 +9,7 @@ import com.github.amsacode.predict4java.GroundStationPosition
import com.github.amsacode.predict4java.Position
import com.rtbishop.look4sat.data.SatPass
import com.rtbishop.look4sat.utility.PrefsManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.util.*
@@ -23,8 +24,8 @@ class MapViewModel @ViewModelInject constructor(prefsManager: PrefsManager) : Vi
private val _gsp = MutableLiveData(prefsManager.getStationPosition())
fun getGSP(): LiveData<GroundStationPosition> = _gsp
private val _selectedPass = MutableLiveData<SatPass?>()
fun getSelectedPass(): LiveData<SatPass?> = _selectedPass
private val _selectedPass = MutableLiveData<SatPass>()
fun getSelectedPass(): LiveData<SatPass> = _selectedPass
private val _satMarkers = MutableLiveData<Map<SatPass, Position>>()
fun getSatMarkers(): LiveData<Map<SatPass, Position>> = _satMarkers
@@ -36,16 +37,15 @@ class MapViewModel @ViewModelInject constructor(prefsManager: PrefsManager) : Vi
}
private fun calculateSatPos(passes: List<SatPass>) {
viewModelScope.launch {
viewModelScope.launch(Dispatchers.Default) {
while (true) {
val passesMap = mutableMapOf<SatPass, Position>()
dateNow.time = System.currentTimeMillis()
passes.forEach {
val satPos = it.predictor.getSatPos(dateNow)
val osmPos = getOsmPosition(satPos.latitude, satPos.longitude, true)
passesMap[it] = osmPos
passesMap[it] = getOsmPosition(satPos.latitude, satPos.longitude, true)
}
_satMarkers.value = passesMap
_satMarkers.postValue(passesMap)
delay(2000)
}
}
@@ -2,6 +2,7 @@ package com.rtbishop.look4sat.ui.views
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Path
import android.view.View
@@ -23,7 +24,7 @@ class PolarView(context: Context) : View(context) {
private val polarCenter = polarWidth / 2f
private val scale = resources.displayMetrics.density
private val radius = polarWidth * 0.48f
private val txtSize = scale * 16
private val txtSize = scale * 16f
private val path: Path = Path()
private val piDiv2 = Math.PI / 2.0
@@ -31,7 +32,7 @@ class PolarView(context: Context) : View(context) {
isAntiAlias = true
color = ContextCompat.getColor(context, R.color.greyLight)
style = Paint.Style.STROKE
strokeWidth = scale * 1.6f
strokeWidth = scale * 2f
}
private val txtPaint = Paint().apply {
isAntiAlias = true
@@ -40,9 +41,9 @@ class PolarView(context: Context) : View(context) {
}
private val trackPaint = Paint().apply {
isAntiAlias = true
color = ContextCompat.getColor(context, R.color.satTrack)
color = Color.RED
style = Paint.Style.STROKE
strokeWidth = scale * 1.6f
strokeWidth = scale * 2f
}
private val satPaint = Paint().apply {
isAntiAlias = true
@@ -96,7 +97,7 @@ class PolarView(context: Context) : View(context) {
if (satPos.elevation > 0) {
val x = sph2CartX(satPos.azimuth, satPos.elevation, radius.toDouble())
val y = sph2CartY(satPos.azimuth, satPos.elevation, radius.toDouble())
cvs.drawCircle(x, -y, txtSize / 2.6f, satPaint)
cvs.drawCircle(x, -y, txtSize / 2.4f, satPaint)
}
}