Further changes to fragments and layouts

This commit is contained in:
Arty Bishop committed 2022-01-09 18:01:45 +00:00
1 parent 9c137ada9f
commit ad3bdff823
54 files changed
+306 -372

No files matched your search

@@ -42,7 +42,6 @@ class PreferencesSource @Inject constructor(
const val keyModes = "satModes"
const val keyCompass = "compass"
const val keyRadarSweep = "radarSweep"
const val keyTextLabels = "shouldUseTextLabels"
const val keyTimeUTC = "timeUTC"
const val keyHoursAhead = "hoursAhead"
const val keyMinElevation = "minElevation"
@@ -107,10 +106,6 @@ class PreferencesSource @Inject constructor(
return preferences.getInt(keyMinElevation, 16).toDouble()
}
fun shouldUseTextLabels(): Boolean {
return preferences.getBoolean(keyTextLabels, false)
}
fun getUseUTC(): Boolean {
return preferences.getBoolean(keyTimeUTC, false)
}
@@ -189,7 +184,7 @@ class PreferencesSource @Inject constructor(
override fun loadDataSources(): List<String> {
val sourcesList = preferences.getStringSet(keyDataSources, null)?.toList()
return if (sourcesList.isNullOrEmpty()) defaultSources else sourcesList
return if (sourcesList.isNullOrEmpty()) defaultSources else sourcesList.sortedDescending()
}
override fun saveDataSources(sources: List<String>) {
@@ -1,40 +0,0 @@
/*
* Look4Sat. Amateur radio satellite tracker and pass predictor.
* Copyright (C) 2019-2021 Arty Bishop (bishop.arty@gmail.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rtbishop.look4sat.framework.local
import androidx.room.*
import com.rtbishop.look4sat.framework.model.Source
@Dao
interface SourcesDao {
@Query("SELECT sourceUrl FROM sources")
suspend fun getSources(): List<String>
@Transaction
suspend fun updateSources(sources: List<Source>) {
deleteSources()
insertSources(sources)
}
@Query("DELETE from sources")
suspend fun deleteSources()
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertSources(sources: List<Source>)
}
@@ -101,7 +101,7 @@ class MapFragment : Fragment(R.layout.fragment_map) {
Marker(mapView).apply {
setInfoWindow(null)
setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM)
icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_map_pos)
icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_pos)
position = GeoPoint(stationPos.latitude, stationPos.longitude)
mapView.overlays[0] = this
mapView.invalidate()
@@ -18,12 +18,12 @@
package com.rtbishop.look4sat.presentation.mapScreen
import androidx.lifecycle.*
import com.rtbishop.look4sat.domain.predict.Predictor
import com.rtbishop.look4sat.domain.DataRepository
import com.rtbishop.look4sat.framework.PreferencesSource
import com.rtbishop.look4sat.domain.predict.GeoPos
import com.rtbishop.look4sat.domain.QthConverter
import com.rtbishop.look4sat.domain.predict.GeoPos
import com.rtbishop.look4sat.domain.predict.Predictor
import com.rtbishop.look4sat.domain.predict.Satellite
import com.rtbishop.look4sat.framework.PreferencesSource
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.*
import java.util.*
@@ -35,7 +35,7 @@ import kotlin.math.min
class MapViewModel @Inject constructor(
private val dataRepository: DataRepository,
private val predictor: Predictor,
private val preferences: PreferencesSource,
preferences: PreferencesSource,
) : ViewModel() {
private val stationPos = preferences.loadStationPosition()
@@ -61,10 +61,6 @@ class MapViewModel @Inject constructor(
private val _satPositions = MutableLiveData<Map<Satellite, GeoPos>>()
val satPositions: LiveData<Map<Satellite, GeoPos>> = _satPositions
fun shouldUseTextLabels(): Boolean {
return preferences.shouldUseTextLabels()
}
fun scrollSelection(decrement: Boolean) {
if (allSatList.isNotEmpty()) {
val index = allSatList.indexOf(selectedSat)
@@ -76,8 +76,8 @@ class PassesFragment : Fragment(R.layout.fragment_passes), PassesAdapter.PassesC
})
}
passesSwipe.apply {
setColorSchemeResources(R.color.greySurface)
setProgressBackgroundColorSchemeResource(R.color.themeLight)
setColorSchemeResources(R.color.surfaceToolbar)
setProgressBackgroundColorSchemeResource(R.color.themeAccent)
setOnRefreshListener { passesViewModel.forceCalculation() }
}
passesFilter.setOnClickListener { findNavController().navigate(R.id.nav_pass_prefs) }
@@ -27,9 +27,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.SimpleItemAnimator
import com.rtbishop.look4sat.R
import com.rtbishop.look4sat.databinding.FragmentRadarBinding
import com.rtbishop.look4sat.framework.PreferencesSource
import com.rtbishop.look4sat.domain.predict.SatPass
import com.rtbishop.look4sat.domain.predict.SatPos
import com.rtbishop.look4sat.framework.PreferencesSource
import com.rtbishop.look4sat.presentation.ItemDivider
import com.rtbishop.look4sat.presentation.navigateSafe
import com.rtbishop.look4sat.presentation.toTimerString
@@ -105,35 +105,11 @@ class RadarFragment : Fragment(R.layout.fragment_radar) {
orientation.third
)
})
binding.radarToMapButton.setOnClickListener {
binding.radarMap.setOnClickListener {
val bundle = bundleOf("catNum" to pass.catNum)
findNavController().navigateSafe(R.id.action_radar_to_map, bundle)
}
}
// binding.radarNotifyButton.setOnClickListener {
// this.context?.let { context ->
//
// val choicesList = arrayOf(
// getString(R.string.notification_on_start_pass),
// getString(R.string.notification_5_min_before),
// getString(R.string.notification_10_min_before),
// getString(R.string.notification_15_min_before),
// )
//
// MaterialAlertDialogBuilder(context)
// .setTitle(getString(R.string.notification_title))
// .setSingleChoiceItems(choicesList, -1) { dialog, which ->
// // TODO in this place should set a notification by NotificationBuilder
// Toast.makeText(context, "Reminder was saved", Toast.LENGTH_SHORT).show()
// dialog.dismiss()
// }
// .setNegativeButton(getString(R.string.btn_cancel)) { _, _ ->
// // noop
// }
// .show()
// }
// }
}
private fun setPassText(satPass: SatPass, satPos: SatPos, binding: FragmentRadarBinding) {
@@ -157,7 +133,9 @@ class RadarFragment : Fragment(R.layout.fragment_radar) {
binding.radarTimer.text = millisBeforeEnd.toTimerString()
if (timeNow > satPass.losTime) {
binding.radarTimer.text = 0L.toTimerString()
findNavController().navigateSafe(R.id.action_radar_to_passes)
// findNavController().navigateSafe(R.id.action_radar_to_passes)
findNavController().popBackStack(R.id.nav_passes, true)
// requireActivity().onNavigateUp()
}
}
} else {
@@ -29,7 +29,7 @@ import kotlin.math.sin
class RadarView(context: Context) : View(context) {
private val defaultColor = ContextCompat.getColor(context, R.color.themeLight)
private val defaultColor = ContextCompat.getColor(context, R.color.themeAccent)
private val scale = resources.displayMetrics.density
private val radarWidth = resources.displayMetrics.widthPixels
private val radarRadius = radarWidth * 0.48f
@@ -38,7 +38,7 @@ class RadarView(context: Context) : View(context) {
private var position: SatPos? = null
private var positions: List<SatPos> = emptyList()
private var radarColor = ContextCompat.getColor(context, R.color.greyLight)
private var radarColor = ContextCompat.getColor(context, R.color.themeLight)
private var radarCircleNum = 3
private var radarPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = radarColor
@@ -79,7 +79,7 @@ class RadarView(context: Context) : View(context) {
private val arrowPath = Path()
private var arrowPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = ContextCompat.getColor(context, R.color.themeLight)
color = ContextCompat.getColor(context, R.color.themeAccent)
style = Paint.Style.FILL
strokeWidth = strokeSize
}
@@ -135,7 +135,7 @@ class RadarView(context: Context) : View(context) {
isTrackCreated = true
}
canvas.drawColor(ContextCompat.getColor(context, R.color.greyDark))
canvas.drawColor(ContextCompat.getColor(context, R.color.surfaceBg))
drawRadarCircle(canvas, cx, cy, radarRadius)
drawRadarCross(canvas, cx, cy, radarRadius)
drawRadarText(canvas, cx, radarRadius)