Switched to GridLayoutManager in entries recycler, classes moved

This commit is contained in:
Arty Bishop committed 2021-10-27 21:47:02 +01:00
1 parent db8fe3ce8d
commit af7e027350
51 files changed
+264 -251

No files matched your search

@@ -17,12 +17,12 @@
*/
package com.rtbishop.look4sat.data
import com.rtbishop.look4sat.domain.Repository
import com.rtbishop.look4sat.model.SatEntry
import com.rtbishop.look4sat.model.SatItem
import com.rtbishop.look4sat.model.Transmitter
import com.rtbishop.look4sat.predict4kotlin.Satellite
import com.rtbishop.look4sat.predict4kotlin.TLE
import com.rtbishop.look4sat.domain.SatelliteRepo
import com.rtbishop.look4sat.domain.model.SatEntry
import com.rtbishop.look4sat.domain.model.SatItem
import com.rtbishop.look4sat.domain.model.Transmitter
import com.rtbishop.look4sat.domain.predict.Satellite
import com.rtbishop.look4sat.domain.predict.TLE
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
@@ -35,7 +35,7 @@ class DataRepository(
private val localSource: LocalDataSource,
private val remoteSource: RemoteDataSource,
private val repoDispatcher: CoroutineDispatcher
) : Repository {
) : SatelliteRepo {
override fun getSatItems(): Flow<List<SatItem>> {
return localSource.getEntriesWithModes()
@@ -17,10 +17,10 @@
*/
package com.rtbishop.look4sat.data
import com.rtbishop.look4sat.model.SatEntry
import com.rtbishop.look4sat.model.SatItem
import com.rtbishop.look4sat.model.Transmitter
import com.rtbishop.look4sat.predict4kotlin.Satellite
import com.rtbishop.look4sat.domain.model.SatEntry
import com.rtbishop.look4sat.domain.model.SatItem
import com.rtbishop.look4sat.domain.model.Transmitter
import com.rtbishop.look4sat.domain.predict.Satellite
import kotlinx.coroutines.flow.Flow
interface LocalDataSource {
@@ -17,7 +17,7 @@
*/
package com.rtbishop.look4sat.data
import com.rtbishop.look4sat.model.Transmitter
import com.rtbishop.look4sat.domain.model.Transmitter
import java.io.InputStream
interface RemoteDataSource {
@@ -15,7 +15,7 @@
* 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.common
package com.rtbishop.look4sat.domain
object Constants {
@@ -24,5 +24,4 @@ object Constants {
const val URL_AMSAT = "https://amsat.org/tle/current/nasabare.txt"
const val URL_PRISM_CLASSFD = "https://www.prismnet.com/~mmccants/tles/classfd.zip"
const val URL_PRISM_INTEL = "https://www.prismnet.com/~mmccants/tles/inttles.zip"
}
@@ -15,7 +15,7 @@
* 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.common
package com.rtbishop.look4sat.domain
sealed class DataState<out T> {
data class Success<out T>(val data: T) : DataState<T>()
@@ -17,14 +17,14 @@
*/
package com.rtbishop.look4sat.domain
import com.rtbishop.look4sat.predict4kotlin.GeoPos
import com.rtbishop.look4sat.domain.predict.GeoPos
import kotlin.math.round
object QthConverter {
fun qthToPosition(qthString: String): GeoPos? {
val trimmedQth = qthString.take(6)
if (!isValidQTH(trimmedQth)) return null
if (!isValidQth(trimmedQth)) return null
val lonFirst = (trimmedQth[0].uppercaseChar().code - 65) * 20
val latFirst = (trimmedQth[1].uppercaseChar().code - 65) * 10
val lonSecond = trimmedQth[2].toString().toInt() * 2
@@ -36,7 +36,7 @@ object QthConverter {
return GeoPos(latitude, longitude)
}
fun positionToQTH(lat: Double, lon: Double): String? {
fun positionToQth(lat: Double, lon: Double): String? {
if (!isValidPosition(lat, lon)) return null
val tempLon = if (lon > 180.0) lon - 360 else lon
val upper = "ABCDEFGHIJKLMNOPQRSTUVWX"
@@ -52,7 +52,7 @@ object QthConverter {
return "$lonFirst$latFirst$lonSecond$latSecond$lonThird$latThird"
}
private fun isValidQTH(qthString: String): Boolean {
private fun isValidQth(qthString: String): Boolean {
val qthPattern = "[a-xA-X][a-xA-X][0-9][0-9][a-xA-X][a-xA-X]".toRegex()
return qthString.matches(qthPattern)
}
@@ -17,13 +17,13 @@
*/
package com.rtbishop.look4sat.domain
import com.rtbishop.look4sat.model.SatItem
import com.rtbishop.look4sat.model.Transmitter
import com.rtbishop.look4sat.predict4kotlin.Satellite
import com.rtbishop.look4sat.domain.model.SatItem
import com.rtbishop.look4sat.domain.model.Transmitter
import com.rtbishop.look4sat.domain.predict.Satellite
import kotlinx.coroutines.flow.Flow
import java.io.InputStream
interface Repository {
interface SatelliteRepo {
fun getSatItems(): Flow<List<SatItem>>
@@ -15,7 +15,7 @@
* 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.model
package com.rtbishop.look4sat.domain.model
data class OMM(
val name: String,
@@ -15,9 +15,9 @@
* 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.model
package com.rtbishop.look4sat.domain.model
import com.rtbishop.look4sat.predict4kotlin.TLE
import com.rtbishop.look4sat.domain.predict.TLE
data class SatEntry(
val tle: TLE,
@@ -15,7 +15,7 @@
* 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.model
package com.rtbishop.look4sat.domain.model
data class SatItem(
val catNum: Int,
@@ -15,7 +15,7 @@
* 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.model
package com.rtbishop.look4sat.domain.model
data class Transmitter(
val uuid: String,
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict
import kotlin.math.*
@@ -15,6 +15,6 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict
data class GeoPos(val latitude: Double, val longitude: Double, val altitude: Double = 0.0)
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict
import kotlin.math.*
@@ -15,9 +15,8 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict
import com.rtbishop.look4sat.domain.*
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict
data class SatPass(
val aosTime: Long,
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict
import kotlin.math.*
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict
import java.util.*
import java.util.concurrent.atomic.AtomicReference
@@ -15,7 +15,7 @@
* 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.predict4kotlin
package com.rtbishop.look4sat.domain.predict
import java.io.InputStream
import kotlin.math.pow
@@ -1,24 +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.usecases
import com.rtbishop.look4sat.domain.Repository
class GetSelectedSatellites(private val dataRepository: Repository) {
suspend operator fun invoke() = dataRepository.getSelectedSatellites()
}
@@ -15,8 +15,9 @@
* 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.domain
package com.rtbishop.look4sat
import com.rtbishop.look4sat.domain.QthConverter
import org.junit.Test
class QthConverterTest {
@@ -29,29 +30,24 @@ class QthConverterTest {
assert(result?.latitude == 48.1458 && result.longitude == 11.6250)
result = QthConverter.qthToPosition("gf15vc")
assert(result?.latitude == -34.8958 && result.longitude == -56.2083)
result = QthConverter.qthToPosition("fm18LW")
assert(result?.latitude == 38.9375 && result.longitude == -77.0417)
}
@Test
fun `Given invalid QTH returns null`() {
var result = QthConverter.qthToPosition("ZZ00zz")
assert(result == null)
result = QthConverter.qthToPosition("JN58tz")
assert(result == null)
assert(QthConverter.qthToPosition("ZZ00zz") == null)
assert(QthConverter.qthToPosition("JN58") == null)
}
@Test
fun `Given valid POS returns correct QTH`() {
assert(QthConverter.positionToQTH(51.4878, -0.2146) == "IO91vl")
assert(QthConverter.positionToQTH(48.1466, 11.6083) == "JN58td")
assert(QthConverter.positionToQTH(-34.91, -56.2116) == "GF15vc")
assert(QthConverter.positionToQTH(38.92, -77.065) == "FM18lw")
assert(QthConverter.positionToQth(51.4878, -0.2146) == "IO91vl")
assert(QthConverter.positionToQth(48.1466, 11.6083) == "JN58td")
assert(QthConverter.positionToQth(-34.91, -56.2116) == "GF15vc")
}
@Test
fun `Given invalid POS returns null`() {
assert(QthConverter.positionToQTH(91.0542, -170.1142) == null)
assert(QthConverter.positionToQTH(89.0542, -240.1142) == null)
assert(QthConverter.positionToQth(91.0542, -170.1142) == null)
assert(QthConverter.positionToQth(89.0542, -240.1142) == null)
}
}
@@ -15,8 +15,9 @@
* 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.predict4kotlin
package com.rtbishop.look4sat
import com.rtbishop.look4sat.domain.predict.TLE
import org.junit.Test
class TleParserTest {