Satellite tracker and pass predictor for Android, inspired by Gpredict
Kotlin amsatcelestrakgpsham-radiohamlibhamradiokotlinnasaradiosatellitesatellite-datasatellite-positionsatellite-predictionsatellitessatnogssdrspacespacexstarlink
Implemented Clean architecture, removed redundant dependencies
Arty Bishope9a6471b6d5f
diff --git a/app/build.gradle b/app/build.gradleindex a024cd57..3f57f618 100644--- a/app/build.gradle+++ b/app/build.gradle@@ -32,12 +32,6 @@ android {}}}-- configurations {- all {- exclude module: "commons-logging"- }- }compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8@@ -68,7 +62,6 @@ dependencies {implementation "com.squareup.retrofit2:retrofit:$retrofit_version"implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"- implementation "com.github.davidmoten:predict4java:$predict4java_version"implementation "org.osmdroid:osmdroid-android:$osmdroid_version"implementation "com.jakewharton.timber:timber:$timber_version"diff --git a/app/schemas/com.rtbishop.look4sat.framework.db.SatelliteDb/1.json b/app/schemas/com.rtbishop.look4sat.framework.db.SatelliteDb/1.jsonnew file mode 100644index 00000000..077b4a03--- /dev/null+++ b/app/schemas/com.rtbishop.look4sat.framework.db.SatelliteDb/1.json@@ -0,0 +1,114 @@+{+ "formatVersion": 1,+ "database": {+ "version": 1,+ "identityHash": "53fa623fc55b279c50d33e6263866a89",+ "entities": [+ {+ "tableName": "entries",+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tle` TEXT NOT NULL, `catNum` INTEGER NOT NULL, `name` TEXT NOT NULL, `isSelected` INTEGER NOT NULL, PRIMARY KEY(`catNum`))",+ "fields": [+ {+ "fieldPath": "tle",+ "columnName": "tle",+ "affinity": "TEXT",+ "notNull": true+ },+ {+ "fieldPath": "catNum",+ "columnName": "catNum",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "name",+ "columnName": "name",+ "affinity": "TEXT",+ "notNull": true+ },+ {+ "fieldPath": "isSelected",+ "columnName": "isSelected",+ "affinity": "INTEGER",+ "notNull": true+ }+ ],+ "primaryKey": {+ "columnNames": [+ "catNum"+ ],+ "autoGenerate": false+ },+ "indices": [],+ "foreignKeys": []+ },+ {+ "tableName": "transmitters",+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uuid` TEXT NOT NULL, `info` TEXT NOT NULL, `isAlive` INTEGER NOT NULL, `downlink` INTEGER, `uplink` INTEGER, `mode` TEXT, `isInverted` INTEGER NOT NULL, `catNum` INTEGER NOT NULL, PRIMARY KEY(`uuid`))",+ "fields": [+ {+ "fieldPath": "uuid",+ "columnName": "uuid",+ "affinity": "TEXT",+ "notNull": true+ },+ {+ "fieldPath": "info",+ "columnName": "info",+ "affinity": "TEXT",+ "notNull": true+ },+ {+ "fieldPath": "isAlive",+ "columnName": "isAlive",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "downlink",+ "columnName": "downlink",+ "affinity": "INTEGER",+ "notNull": false+ },+ {+ "fieldPath": "uplink",+ "columnName": "uplink",+ "affinity": "INTEGER",+ "notNull": false+ },+ {+ "fieldPath": "mode",+ "columnName": "mode",+ "affinity": "TEXT",+ "notNull": false+ },+ {+ "fieldPath": "isInverted",+ "columnName": "isInverted",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "catNum",+ "columnName": "catNum",+ "affinity": "INTEGER",+ "notNull": true+ }+ ],+ "primaryKey": {+ "columnNames": [+ "uuid"+ ],+ "autoGenerate": false+ },+ "indices": [],+ "foreignKeys": []+ }+ ],+ "views": [],+ "setupQueries": [+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '53fa623fc55b279c50d33e6263866a89')"+ ]+ }+}\ No newline at end of filediff --git a/app/src/main/java/com/rtbishop/look4sat/data/api/SatelliteService.kt b/app/src/main/java/com/rtbishop/look4sat/data/api/SatelliteService.ktdeleted file mode 100644index 3d11217e..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/api/SatelliteService.kt+++ /dev/null@@ -1,35 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.api--import com.rtbishop.look4sat.data.model.SatTrans-import okhttp3.ResponseBody-import retrofit2.Response-import retrofit2.http.GET-import retrofit2.http.Streaming-import retrofit2.http.Url--interface SatelliteService {-- @Streaming- @GET- suspend fun fetchFileByUrl(@Url url: String): Response<ResponseBody>-- @GET("transmitters/")- suspend fun fetchTransmitters(): List<SatTrans>-}diff --git a/app/src/main/java/com/rtbishop/look4sat/data/database/RoomConverters.kt b/app/src/main/java/com/rtbishop/look4sat/data/database/RoomConverters.ktdeleted file mode 100644index 5528a062..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/database/RoomConverters.kt+++ /dev/null@@ -1,53 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.database--import androidx.room.TypeConverter-import com.github.amsacode.predict4java.Satellite-import com.github.amsacode.predict4java.SatelliteFactory-import com.github.amsacode.predict4java.TLE-import com.squareup.moshi.JsonAdapter-import com.squareup.moshi.Moshi--object RoomConverters {-- private lateinit var tleAdapter: JsonAdapter<TLE>-- fun initialize(moshi: Moshi) {- tleAdapter = moshi.adapter(TLE::class.java)- }-- @JvmStatic- @TypeConverter- fun tleToString(tle: TLE): String {- return tleAdapter.toJson(tle)- }-- @JvmStatic- @TypeConverter- fun tleFromString(string: String): TLE? {- return tleAdapter.fromJson(string)- }-- @JvmStatic- @TypeConverter- fun satFromString(string: String): Satellite? {- val tle = tleAdapter.fromJson(string)- return SatelliteFactory.createSatellite(tle)- }-}diff --git a/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDao.kt b/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDao.ktdeleted file mode 100644index e55fc2f8..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDao.kt+++ /dev/null@@ -1,81 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.database--import androidx.room.*-import com.github.amsacode.predict4java.Satellite-import com.rtbishop.look4sat.data.model.SatEntry-import com.rtbishop.look4sat.data.model.SatItem-import com.rtbishop.look4sat.data.model.SatTrans-import kotlinx.coroutines.flow.Flow--@Dao-interface SatelliteDao {-- @Transaction- @Query("SELECT catNum, name, isSelected FROM entries ORDER BY name ASC")- fun getSatItems(): Flow<List<SatItem>>-- @Query("SELECT * FROM transmitters WHERE catNum = :catNum")- fun getSatTransmitters(catNum: Int): Flow<List<SatTrans>>-- @Query("SELECT tle FROM entries WHERE isSelected = 1")- suspend fun getSelectedSatellites(): List<Satellite>-- @Query("SELECT catNum FROM entries WHERE isSelected = 1")- suspend fun getSelectedCatNums(): List<Int>-- @Transaction- suspend fun updateEntries(entries: List<SatEntry>) {- val selectedCatNums = getSelectedCatNums()- insertEntries(entries)- restoreEntriesSelection(selectedCatNums, true)- }-- @Insert(onConflict = OnConflictStrategy.REPLACE)- suspend fun insertEntries(entries: List<SatEntry>)-- @Transaction- suspend fun restoreEntriesSelection(catNums: List<Int>, isSelected: Boolean) {- clearEntriesSelection()- catNums.forEach { catNum -> updateEntrySelection(catNum, isSelected) }- }-- @Query("UPDATE entries SET isSelected = 0")- suspend fun clearEntriesSelection()-- @Query("UPDATE entries SET isSelected = :isSelected WHERE catNum = :catNum")- suspend fun updateEntrySelection(catNum: Int, isSelected: Boolean)-- @Transaction- suspend fun updateEntriesSelection(catNums: List<Int>, isSelected: Boolean) {- catNums.forEach { catNum -> updateEntrySelection(catNum, isSelected) }- }-- @Transaction- suspend fun updateTransmitters(transmitters: List<SatTrans>) {- deleteTransmitters()- insertTransmitters(transmitters)- }-- @Query("DELETE from transmitters")- suspend fun deleteTransmitters()-- @Insert(onConflict = OnConflictStrategy.REPLACE)- suspend fun insertTransmitters(transmitters: List<SatTrans>)-}diff --git a/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDb.kt b/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDb.ktdeleted file mode 100644index 5fa8a779..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDb.kt+++ /dev/null@@ -1,48 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.database--import androidx.room.Database-import androidx.room.RoomDatabase-import androidx.room.TypeConverters-import androidx.room.migration.Migration-import androidx.sqlite.db.SupportSQLiteDatabase-import com.rtbishop.look4sat.data.model.SatEntry-import com.rtbishop.look4sat.data.model.SatTrans--@Database(entities = [SatEntry::class, SatTrans::class], version = 3)-@TypeConverters(RoomConverters::class)-abstract class SatelliteDb : RoomDatabase() {-- abstract fun satelliteDao(): SatelliteDao-}--val MIGRATION_1_2 = object : Migration(1, 2) {- override fun migrate(database: SupportSQLiteDatabase) {- database.execSQL("DROP TABLE sources")- }-}--val MIGRATION_2_3 = object : Migration(2, 3) {- override fun migrate(database: SupportSQLiteDatabase) {- database.execSQL("CREATE TABLE trans_backup (uuid TEXT NOT NULL, info TEXT NOT NULL, isAlive INTEGER NOT NULL, downlink INTEGER, uplink INTEGER, mode TEXT, isInverted INTEGER NOT NULL, catNum INTEGER NOT NULL, PRIMARY KEY(uuid))")- database.execSQL("INSERT INTO trans_backup (uuid, info, isAlive, downlink, uplink, mode, isInverted, catNum) SELECT uuid, description, isAlive, downlinkLow, uplinkLow, mode, isInverted, catNum FROM transmitters")- database.execSQL("DROP TABLE transmitters")- database.execSQL("ALTER TABLE trans_backup RENAME TO transmitters")- }-}diff --git a/app/src/main/java/com/rtbishop/look4sat/data/model/Result.kt b/app/src/main/java/com/rtbishop/look4sat/data/model/Result.ktdeleted file mode 100644index 9a849352..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/model/Result.kt+++ /dev/null@@ -1,24 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.model--sealed class Result<out T : Any> {- data class Success<out T : Any>(val data: T) : Result<T>()- data class Error(val exception: Throwable) : Result<Nothing>()- object InProgress : Result<Nothing>()-}diff --git a/app/src/main/java/com/rtbishop/look4sat/data/model/SatEntry.kt b/app/src/main/java/com/rtbishop/look4sat/data/model/SatEntry.ktdeleted file mode 100644index f8b4e528..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/model/SatEntry.kt+++ /dev/null@@ -1,30 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.model--import androidx.room.Entity-import androidx.room.PrimaryKey-import com.github.amsacode.predict4java.TLE--@Entity(tableName = "entries")-data class SatEntry(- val tle: TLE,- var isSelected: Boolean = false,- @PrimaryKey val catNum: Int = tle.catnum,- val name: String = tle.name-)diff --git a/app/src/main/java/com/rtbishop/look4sat/data/model/SatItem.kt b/app/src/main/java/com/rtbishop/look4sat/data/model/SatItem.ktdeleted file mode 100644index b5902a1f..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/model/SatItem.kt+++ /dev/null@@ -1,33 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.model--import androidx.room.Relation--data class SatItem(- val catNum: Int,- val name: String,- var isSelected: Boolean,- @Relation(- parentColumn = "catNum",- entity = SatTrans::class,- entityColumn = "catNum",- projection = ["mode"]- )- val modes: List<String>-)diff --git a/app/src/main/java/com/rtbishop/look4sat/data/model/SatPass.kt b/app/src/main/java/com/rtbishop/look4sat/data/model/SatPass.ktdeleted file mode 100644index b66d22c3..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/model/SatPass.kt+++ /dev/null@@ -1,46 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.model--import com.rtbishop.look4sat.utility.PassPredictor-import java.util.*--data class SatPass(- val catNum: Int,- val name: String,- val isDeepSpace: Boolean,- private val aosTime: Long,- val aosAzimuth: Double,- private val losTime: Long,- val losAzimuth: Double,- private val tcaTime: Long,- val tcaAzimuth: Double,- val altitude: Double,- val maxElevation: Double,- val predictor: PassPredictor,- var progress: Int = 0-) {- val aosDate: Date- get() = Date(aosTime)-- val losDate: Date- get() = Date(losTime)-- val tcaDate: Date- get() = Date(tcaTime)-}diff --git a/app/src/main/java/com/rtbishop/look4sat/data/model/SatTrans.kt b/app/src/main/java/com/rtbishop/look4sat/data/model/SatTrans.ktdeleted file mode 100644index 2d1b42c6..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/model/SatTrans.kt+++ /dev/null@@ -1,34 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.model--import androidx.room.Entity-import androidx.room.PrimaryKey-import com.squareup.moshi.Json--@Entity(tableName = "transmitters")-data class SatTrans(- @PrimaryKey @field:Json(name = "uuid") val uuid: String,- @field:Json(name = "description") val info: String,- @field:Json(name = "alive") val isAlive: Boolean,- @field:Json(name = "downlink_low") var downlink: Long?,- @field:Json(name = "uplink_low") var uplink: Long?,- @field:Json(name = "mode") val mode: String?,- @field:Json(name = "invert") val isInverted: Boolean,- @field:Json(name = "norad_cat_id") val catNum: Int-)diff --git a/app/src/main/java/com/rtbishop/look4sat/data/model/SelectedSat.kt b/app/src/main/java/com/rtbishop/look4sat/data/model/SelectedSat.ktdeleted file mode 100644index 98e8e9ec..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/model/SelectedSat.kt+++ /dev/null@@ -1,35 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.model--import com.github.amsacode.predict4java.Position-import com.github.amsacode.predict4java.Satellite-import org.osmdroid.views.overlay.Overlay--data class SelectedSat(- val pass: Satellite,- val catNum: Int,- val name: String,- val range: Double,- val altitude: Double,- val velocity: Double,- val qthLoc: String,- val osmPos: Position,- val footprint: Overlay,- val groundTrack: Overlay-)diff --git a/app/src/main/java/com/rtbishop/look4sat/data/model/TleSource.kt b/app/src/main/java/com/rtbishop/look4sat/data/model/TleSource.ktdeleted file mode 100644index 58c261df..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/model/TleSource.kt+++ /dev/null@@ -1,20 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.model--class TleSource(var url: String = String())diff --git a/app/src/main/java/com/rtbishop/look4sat/data/repository/SatelliteRepo.kt b/app/src/main/java/com/rtbishop/look4sat/data/repository/SatelliteRepo.ktdeleted file mode 100644index 16cf272f..00000000--- a/app/src/main/java/com/rtbishop/look4sat/data/repository/SatelliteRepo.kt+++ /dev/null@@ -1,127 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.data.repository--import android.content.ContentResolver-import android.net.Uri-import com.github.amsacode.predict4java.Satellite-import com.github.amsacode.predict4java.TLE-import com.rtbishop.look4sat.data.api.SatelliteService-import com.rtbishop.look4sat.data.database.SatelliteDao-import com.rtbishop.look4sat.data.model.SatEntry-import com.rtbishop.look4sat.data.model.SatItem-import com.rtbishop.look4sat.data.model.SatTrans-import com.rtbishop.look4sat.data.model.TleSource-import com.rtbishop.look4sat.di.IoDispatcher-import kotlinx.coroutines.CoroutineDispatcher-import kotlinx.coroutines.coroutineScope-import kotlinx.coroutines.flow.Flow-import kotlinx.coroutines.launch-import kotlinx.coroutines.withContext-import java.io.InputStream-import java.util.zip.ZipInputStream-import javax.inject.Inject-import javax.inject.Singleton--@Singleton-class SatelliteRepo @Inject constructor(- private val resolver: ContentResolver,- private val satelliteDao: SatelliteDao,- private val satelliteService: SatelliteService,- @IoDispatcher private val ioDispatcher: CoroutineDispatcher-) {-- fun getSatItems(): Flow<List<SatItem>> {- return satelliteDao.getSatItems()- }-- fun getSatTransmitters(catNum: Int): Flow<List<SatTrans>> {- return satelliteDao.getSatTransmitters(catNum)- }-- suspend fun getSelectedSatellites(): List<Satellite> {- return satelliteDao.getSelectedSatellites()- }-- suspend fun importSatDataFromFile(uri: Uri) {- runCatching {- resolver.openInputStream(uri)?.use { stream ->- val entries = importEntriesFromStreams(listOf(stream))- satelliteDao.updateEntries(entries)- }- }.onFailure { throw it }- }-- suspend fun importSatDataFromWeb(sources: List<TleSource>) {- coroutineScope {- launch { importEntriesFromSources(sources) }- launch { importTransmitters() }- }- }-- suspend fun updateEntriesSelection(catNums: List<Int>, isSelected: Boolean) {- satelliteDao.updateEntriesSelection(catNums, isSelected)- }-- private suspend fun importEntriesFromSources(sources: List<TleSource>) {- val streams = getStreamsForSources(sources)- val entries = importEntriesFromStreams(streams)- satelliteDao.updateEntries(entries)- }-- private suspend fun importTransmitters() {- val transmitters = satelliteService.fetchTransmitters().filter { it.isAlive }- satelliteDao.updateTransmitters(transmitters)- }-- private suspend fun getStreamsForSources(sources: List<TleSource>): List<InputStream> {- val streams = mutableListOf<InputStream>()- sources.forEach { tleSource ->- satelliteService.fetchFileByUrl(tleSource.url).body()?.byteStream()?.let { stream ->- if (tleSource.url.contains(".zip", true)) {- streams.add(getZipStream(stream))- } else {- streams.add(stream)- }- }- }- return streams- }-- private suspend fun getZipStream(inputStream: InputStream): InputStream {- var stream: InputStream- withContext(ioDispatcher) {- ZipInputStream(inputStream).apply {- nextEntry- stream = this- }- }- return stream- }-- private suspend fun importEntriesFromStreams(streams: List<InputStream>): List<SatEntry> {- val importedEntries = mutableListOf<SatEntry>()- withContext(ioDispatcher) {- streams.forEach { stream ->- val entries = TLE.importSat(stream).map { tle -> SatEntry(tle) }- importedEntries.addAll(entries)- }- }- return importedEntries- }-}diff --git a/app/src/main/java/com/rtbishop/look4sat/di/InteractorsModule.kt b/app/src/main/java/com/rtbishop/look4sat/di/InteractorsModule.ktnew file mode 100644index 00000000..ed445956--- /dev/null+++ b/app/src/main/java/com/rtbishop/look4sat/di/InteractorsModule.kt@@ -0,0 +1,43 @@+package com.rtbishop.look4sat.di++import com.rtbishop.look4sat.domain.SatelliteRepo+import com.rtbishop.look4sat.interactors.*+import dagger.Module+import dagger.Provides+import dagger.hilt.InstallIn+import dagger.hilt.components.SingletonComponent++@Module+@InstallIn(SingletonComponent::class)+object InteractorsModule {++ @Provides+ fun provideGetSatItemsUseCase(satelliteRepo: SatelliteRepo): GetSatItems {+ return GetSatItems(satelliteRepo)+ }++ @Provides+ fun provideGetSelectedSatellitesUseCase(satelliteRepo: SatelliteRepo): GetSelectedSatellites {+ return GetSelectedSatellites(satelliteRepo)+ }++ @Provides+ fun provideGetTransmittersForSatUseCase(satelliteRepo: SatelliteRepo): GetTransmittersForSat {+ return GetTransmittersForSat(satelliteRepo)+ }++ @Provides+ fun provideImportDataFromFileUseCase(satelliteRepo: SatelliteRepo): ImportDataFromFile {+ return ImportDataFromFile(satelliteRepo)+ }++ @Provides+ fun provideImportDataFromWebUseCase(satelliteRepo: SatelliteRepo): ImportDataFromWeb {+ return ImportDataFromWeb(satelliteRepo)+ }++ @Provides+ fun provideUpdateEntriesSelectionUseCase(satelliteRepo: SatelliteRepo): UpdateEntriesSelection {+ return UpdateEntriesSelection(satelliteRepo)+ }+}diff --git a/app/src/main/java/com/rtbishop/look4sat/di/RepositoryModule.kt b/app/src/main/java/com/rtbishop/look4sat/di/LocalSourceModule.ktsimilarity index 57%rename from app/src/main/java/com/rtbishop/look4sat/di/RepositoryModule.ktrename to app/src/main/java/com/rtbishop/look4sat/di/LocalSourceModule.ktindex f9b50b86..c9110b21 100644--- a/app/src/main/java/com/rtbishop/look4sat/di/RepositoryModule.kt+++ b/app/src/main/java/com/rtbishop/look4sat/di/LocalSourceModule.kt@@ -19,29 +19,55 @@ package com.rtbishop.look4sat.diimport android.content.Contextimport androidx.room.Room-import com.rtbishop.look4sat.data.database.*+import com.rtbishop.look4sat.data.DefaultSatelliteRepo+import com.rtbishop.look4sat.data.LocalDataSource+import com.rtbishop.look4sat.data.RemoteDataSource+import com.rtbishop.look4sat.domain.SatelliteRepo+import com.rtbishop.look4sat.framework.db.RoomConverters+import com.rtbishop.look4sat.framework.db.RoomDataSource+import com.rtbishop.look4sat.framework.db.SatelliteDao+import com.rtbishop.look4sat.framework.db.SatelliteDbimport com.squareup.moshi.Moshiimport dagger.Moduleimport dagger.Providesimport dagger.hilt.InstallInimport dagger.hilt.android.qualifiers.ApplicationContextimport dagger.hilt.components.SingletonComponent+import kotlinx.coroutines.CoroutineDispatcher+import javax.inject.Singleton@Module@InstallIn(SingletonComponent::class)-object RepositoryModule {-+object LocalSourceModule {++ @Provides+ fun provideLocalDataSource(satelliteDao: SatelliteDao): LocalDataSource {+ return RoomDataSource(satelliteDao)+ }++ @Provides+ @Singleton+ fun provideDefaultRepository(+ localSource: LocalDataSource,+ remoteSource: RemoteDataSource,+ @IoDispatcher ioDispatcher: CoroutineDispatcher+ ): SatelliteRepo {+ return DefaultSatelliteRepo(localSource, remoteSource, ioDispatcher)+ }++ @Provides+ fun provideMoshi(): Moshi {+ return Moshi.Builder().build()+ }+@Providesfun provideSatDataDao(db: SatelliteDb): SatelliteDao {return db.satelliteDao()}-+@Providesfun provideSatelliteDb(@ApplicationContext context: Context, moshi: Moshi): SatelliteDb {RoomConverters.initialize(moshi)- return Room.databaseBuilder(context, SatelliteDb::class.java, "satDb")- .addMigrations(MIGRATION_1_2)- .addMigrations(MIGRATION_2_3)- .build()+ return Room.databaseBuilder(context, SatelliteDb::class.java, "SatelliteDb").build()}}diff --git a/app/src/main/java/com/rtbishop/look4sat/di/NetworkModule.kt b/app/src/main/java/com/rtbishop/look4sat/di/RemoteSourceModule.ktsimilarity index 80%rename from app/src/main/java/com/rtbishop/look4sat/di/NetworkModule.ktrename to app/src/main/java/com/rtbishop/look4sat/di/RemoteSourceModule.ktindex e4340bdb..e7a98b2e 100644--- a/app/src/main/java/com/rtbishop/look4sat/di/NetworkModule.kt+++ b/app/src/main/java/com/rtbishop/look4sat/di/RemoteSourceModule.kt@@ -17,8 +17,9 @@*/package com.rtbishop.look4sat.di-import com.rtbishop.look4sat.data.api.SatelliteService-import com.squareup.moshi.Moshi+import com.rtbishop.look4sat.data.RemoteDataSource+import com.rtbishop.look4sat.framework.api.NetworkDataSource+import com.rtbishop.look4sat.framework.api.SatelliteServiceimport dagger.Moduleimport dagger.Providesimport dagger.hilt.InstallIn@@ -28,13 +29,13 @@ import retrofit2.converter.moshi.MoshiConverterFactory@Module@InstallIn(SingletonComponent::class)-object NetworkModule {-+object RemoteSourceModule {+@Provides- fun provideMoshi(): Moshi {- return Moshi.Builder().build()+ fun provideRemoteDataSource(satelliteService: SatelliteService): RemoteDataSource {+ return NetworkDataSource(satelliteService)}-+@Providesfun provideSatDataService(): SatelliteService {return Retrofit.Builder()diff --git a/app/src/main/java/com/rtbishop/look4sat/framework/api/RetrofitDataSource.kt b/app/src/main/java/com/rtbishop/look4sat/framework/api/NetworkDataSource.ktsimilarity index 68%rename from app/src/main/java/com/rtbishop/look4sat/framework/api/RetrofitDataSource.ktrename to app/src/main/java/com/rtbishop/look4sat/framework/api/NetworkDataSource.ktindex 3852fbce..c71f5bd6 100644--- a/app/src/main/java/com/rtbishop/look4sat/framework/api/RetrofitDataSource.kt+++ b/app/src/main/java/com/rtbishop/look4sat/framework/api/NetworkDataSource.kt@@ -4,14 +4,14 @@ import com.rtbishop.look4sat.data.RemoteDataSourceimport com.rtbishop.look4sat.domain.model.SatTransimport java.io.InputStream-class RetrofitDataSource(private val satelliteService: SatelliteService) : RemoteDataSource {+class NetworkDataSource(private val api: SatelliteService) : RemoteDataSource {override suspend fun fetchFileStream(url: String): InputStream? {- return satelliteService.fetchFileByUrl(url).body()?.byteStream()+ return api.fetchFileByUrl(url).body()?.byteStream()}override suspend fun fetchTransmitters(): List<SatTrans> {- return satelliteService.fetchTransmitters().map { trans ->+ return api.fetchTransmitters().map { trans ->SatTrans(trans.uuid, trans.info, trans.isAlive, trans.downlink,trans.uplink, trans.mode, trans.isInverted, trans.catNumdiff --git a/app/src/main/java/com/rtbishop/look4sat/framework/db/RoomConverters.kt b/app/src/main/java/com/rtbishop/look4sat/framework/db/RoomConverters.ktindex 29948ae3..c510a02a 100644--- a/app/src/main/java/com/rtbishop/look4sat/framework/db/RoomConverters.kt+++ b/app/src/main/java/com/rtbishop/look4sat/framework/db/RoomConverters.kt@@ -18,8 +18,8 @@package com.rtbishop.look4sat.framework.dbimport androidx.room.TypeConverter-import com.rtbishop.look4sat.predict4kotlin.Satellite-import com.rtbishop.look4sat.predict4kotlin.TLE+import com.rtbishop.look4sat.domain.predict4kotlin.Satellite+import com.rtbishop.look4sat.domain.predict4kotlin.TLEimport com.squareup.moshi.JsonAdapterimport com.squareup.moshi.Moshidiff --git a/app/src/main/java/com/rtbishop/look4sat/framework/db/RoomDataSource.kt b/app/src/main/java/com/rtbishop/look4sat/framework/db/RoomDataSource.ktindex 1036c718..39dee5da 100644--- a/app/src/main/java/com/rtbishop/look4sat/framework/db/RoomDataSource.kt+++ b/app/src/main/java/com/rtbishop/look4sat/framework/db/RoomDataSource.kt@@ -4,7 +4,7 @@ import com.rtbishop.look4sat.data.LocalDataSourceimport com.rtbishop.look4sat.domain.model.SatEntryimport com.rtbishop.look4sat.domain.model.SatItemimport com.rtbishop.look4sat.domain.model.SatTrans-import com.rtbishop.look4sat.predict4kotlin.Satellite+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport com.rtbishop.look4sat.utility.DataMapperimport kotlinx.coroutines.flow.Flowimport kotlinx.coroutines.flow.map@@ -38,4 +38,4 @@ class RoomDataSource(private val satelliteDao: SatelliteDao) : LocalDataSource {val satTransList = DataMapper.domainTransListToSatTransList(satelliteTrans)satelliteDao.updateTransmitters(satTransList)}-}\ No newline at end of file+}diff --git a/app/src/main/java/com/rtbishop/look4sat/framework/db/SatelliteDao.kt b/app/src/main/java/com/rtbishop/look4sat/framework/db/SatelliteDao.ktindex 0e84875e..443e02cf 100644--- a/app/src/main/java/com/rtbishop/look4sat/framework/db/SatelliteDao.kt+++ b/app/src/main/java/com/rtbishop/look4sat/framework/db/SatelliteDao.kt@@ -21,7 +21,7 @@ import androidx.room.*import com.rtbishop.look4sat.framework.model.SatEntryimport com.rtbishop.look4sat.framework.model.SatItemimport com.rtbishop.look4sat.framework.model.SatTrans-import com.rtbishop.look4sat.predict4kotlin.Satellite+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport kotlinx.coroutines.flow.Flow@Daodiff --git a/app/src/main/java/com/rtbishop/look4sat/framework/model/SatEntry.kt b/app/src/main/java/com/rtbishop/look4sat/framework/model/SatEntry.ktindex 4d7aec2a..04ecf80e 100644--- a/app/src/main/java/com/rtbishop/look4sat/framework/model/SatEntry.kt+++ b/app/src/main/java/com/rtbishop/look4sat/framework/model/SatEntry.kt@@ -19,7 +19,7 @@ package com.rtbishop.look4sat.framework.modelimport androidx.room.Entityimport androidx.room.PrimaryKey-import com.rtbishop.look4sat.predict4kotlin.TLE+import com.rtbishop.look4sat.domain.predict4kotlin.TLE@Entity(tableName = "entries")data class SatEntry(diff --git a/app/src/main/java/com/rtbishop/look4sat/framework/model/SatPass.kt b/app/src/main/java/com/rtbishop/look4sat/framework/model/SatPass.ktdeleted file mode 100644index 6d99ce58..00000000--- a/app/src/main/java/com/rtbishop/look4sat/framework/model/SatPass.kt+++ /dev/null@@ -1,46 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.model--import com.rtbishop.look4sat.utility.PassPredictor-import java.util.*--data class SatPass(- val catNum: Int,- val name: String,- val isDeepSpace: Boolean,- private val aosTime: Long,- val aosAzimuth: Double,- private val losTime: Long,- val losAzimuth: Double,- private val tcaTime: Long,- val tcaAzimuth: Double,- val altitude: Double,- val maxElevation: Double,- val predictor: PassPredictor,- var progress: Int = 0-) {- val aosDate: Date- get() = Date(aosTime)-- val losDate: Date- get() = Date(losTime)-- val tcaDate: Date- get() = Date(tcaTime)-}diff --git a/app/src/main/java/com/rtbishop/look4sat/framework/model/SelectedSat.kt b/app/src/main/java/com/rtbishop/look4sat/framework/model/SelectedSat.ktindex 5b47ff91..df94382b 100644--- a/app/src/main/java/com/rtbishop/look4sat/framework/model/SelectedSat.kt+++ b/app/src/main/java/com/rtbishop/look4sat/framework/model/SelectedSat.kt@@ -17,8 +17,8 @@*/package com.rtbishop.look4sat.framework.model-import com.github.amsacode.predict4java.Position-import com.github.amsacode.predict4java.Satellite+import com.rtbishop.look4sat.domain.predict4kotlin.Position+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport org.osmdroid.views.overlay.Overlaydata class SelectedSat(diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesAdapter.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesAdapter.ktindex 080bc891..5ed24f13 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesAdapter.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesAdapter.kt@@ -22,8 +22,8 @@ import android.view.ViewGroupimport androidx.recyclerview.widget.AsyncListDifferimport androidx.recyclerview.widget.DiffUtilimport androidx.recyclerview.widget.RecyclerView-import com.rtbishop.look4sat.data.model.SatItemimport com.rtbishop.look4sat.databinding.SatItemBinding+import com.rtbishop.look4sat.domain.model.SatItemclass EntriesAdapter : RecyclerView.Adapter<EntriesAdapter.SatItemHolder>() {diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesFragment.ktindex 8e25b1a9..8f0c6e70 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesFragment.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesFragment.kt@@ -27,10 +27,10 @@ import androidx.recyclerview.widget.LinearLayoutManagerimport androidx.recyclerview.widget.SimpleItemAnimatorimport com.google.android.material.snackbar.Snackbarimport com.rtbishop.look4sat.R-import com.rtbishop.look4sat.data.model.Result-import com.rtbishop.look4sat.data.model.SatItem-import com.rtbishop.look4sat.data.model.TleSource+import com.rtbishop.look4sat.framework.model.Resultimport com.rtbishop.look4sat.databinding.FragmentEntriesBinding+import com.rtbishop.look4sat.domain.model.SatItem+import com.rtbishop.look4sat.framework.model.TleSourceimport com.rtbishop.look4sat.utility.RecyclerDividerimport com.rtbishop.look4sat.utility.getNavResultimport com.rtbishop.look4sat.utility.navigateSafediff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesViewModel.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesViewModel.ktindex 9ce948da..37923f3e 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesViewModel.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/entriesScreen/EntriesViewModel.kt@@ -17,6 +17,7 @@*/package com.rtbishop.look4sat.presentation.entriesScreen+import android.content.ContentResolverimport android.content.Contextimport android.net.Uriimport android.widget.SearchView@@ -24,10 +25,13 @@ import androidx.appcompat.app.AlertDialogimport androidx.lifecycle.*import com.google.android.material.dialog.MaterialAlertDialogBuilderimport com.rtbishop.look4sat.R-import com.rtbishop.look4sat.data.model.Result-import com.rtbishop.look4sat.data.model.SatItem-import com.rtbishop.look4sat.data.model.TleSource-import com.rtbishop.look4sat.data.repository.SatelliteRepo+import com.rtbishop.look4sat.domain.model.SatItem+import com.rtbishop.look4sat.framework.model.Result+import com.rtbishop.look4sat.framework.model.TleSource+import com.rtbishop.look4sat.interactors.GetSatItems+import com.rtbishop.look4sat.interactors.ImportDataFromFile+import com.rtbishop.look4sat.interactors.ImportDataFromWeb+import com.rtbishop.look4sat.interactors.UpdateEntriesSelectionimport com.rtbishop.look4sat.utility.PrefsManagerimport dagger.hilt.android.lifecycle.HiltViewModelimport kotlinx.coroutines.flow.collect@@ -40,13 +44,17 @@ import kotlin.system.measureTimeMillis@HiltViewModelclass EntriesViewModel @Inject constructor(private val prefsManager: PrefsManager,- private val satelliteRepo: SatelliteRepo+ private val resolver: ContentResolver,+ private val getSatItems: GetSatItems,+ private val importDataFromFile: ImportDataFromFile,+ private val importDataFromWeb: ImportDataFromWeb,+ private val updateEntriesSelection: UpdateEntriesSelection,) : ViewModel(), EntriesAdapter.EntriesClickListener, SearchView.OnQueryTextListener {private val transModes = MutableLiveData(prefsManager.loadModesSelection())private val currentQuery = MutableLiveData(String())private val itemsWithModes = transModes.switchMap { modes ->- liveData { satelliteRepo.getSatItems().collect { emit(filterByModes(it, modes)) } }+ liveData { getSatItems().collect { emit(filterByModes(it, modes)) } }}private val itemsWithQuery = currentQuery.switchMap { query ->itemsWithModes.map { items -> Result.Success(filterByQuery(items, query)) }@@ -60,11 +68,11 @@ class EntriesViewModel @Inject constructor(fun importSatDataFromFile(uri: Uri) {viewModelScope.launch {_satData.value = Result.InProgress- try {- satelliteRepo.importSatDataFromFile(uri)- } catch (exception: Exception) {- _satData.value = Result.Error(exception)- }+ runCatching {+ resolver.openInputStream(uri)?.use { stream ->+ importDataFromFile(stream)+ }+ }.onFailure { _satData.value = Result.Error(it) }}}@@ -76,9 +84,10 @@ class EntriesViewModel @Inject constructor(val updateMillis = measureTimeMillis {try {prefsManager.saveTleSources(satSources)- satelliteRepo.importSatDataFromWeb(satSources)+ importDataFromWeb(satSources.map { it.url })} catch (exception: Exception) {_satData.value = Result.Error(exception)+ Timber.d(exception)}}Timber.d("Update from WEB took $updateMillis ms")@@ -133,7 +142,7 @@ class EntriesViewModel @Inject constructor(}override fun updateSelection(catNums: List<Int>, isSelected: Boolean) {- viewModelScope.launch { satelliteRepo.updateEntriesSelection(catNums, isSelected) }+ viewModelScope.launch { updateEntriesSelection(catNums, isSelected) }}private fun filterByModes(items: List<SatItem>, modes: List<String>): List<SatItem> {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.ktindex 3d57611b..071fbccd 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@@ -25,11 +25,11 @@ import android.view.Viewimport androidx.core.content.ContextCompatimport androidx.fragment.app.Fragmentimport androidx.fragment.app.viewModels-import com.github.amsacode.predict4java.Position-import com.github.amsacode.predict4java.Satelliteimport com.rtbishop.look4sat.R-import com.rtbishop.look4sat.data.model.SelectedSatimport com.rtbishop.look4sat.databinding.FragmentMapBinding+import com.rtbishop.look4sat.framework.model.SelectedSat+import com.rtbishop.look4sat.domain.predict4kotlin.Position+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport com.rtbishop.look4sat.utility.PrefsManagerimport dagger.hilt.android.AndroidEntryPointimport org.osmdroid.config.Configurationdiff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/mapScreen/MapViewModel.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/mapScreen/MapViewModel.ktindex 3d6f160f..b4bb3a3b 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/mapScreen/MapViewModel.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/mapScreen/MapViewModel.kt@@ -20,11 +20,11 @@ package com.rtbishop.look4sat.presentation.mapScreenimport android.graphics.Colorimport android.graphics.Paintimport androidx.lifecycle.*-import com.github.amsacode.predict4java.Position-import com.github.amsacode.predict4java.SatPos-import com.github.amsacode.predict4java.Satellite-import com.rtbishop.look4sat.data.model.SelectedSat-import com.rtbishop.look4sat.data.repository.SatelliteRepo+import com.rtbishop.look4sat.framework.model.SelectedSat+import com.rtbishop.look4sat.interactors.GetSelectedSatellites+import com.rtbishop.look4sat.domain.predict4kotlin.Position+import com.rtbishop.look4sat.domain.predict4kotlin.SatPos+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport com.rtbishop.look4sat.utility.*import dagger.hilt.android.lifecycle.HiltViewModelimport kotlinx.coroutines.*@@ -39,9 +39,9 @@ import javax.inject.Inject@HiltViewModelclass MapViewModel @Inject constructor(- prefsManager: PrefsManager,- private val satelliteRepo: SatelliteRepo,- private val qthConverter: QthConverter+ private val getSelectedSatellites: GetSelectedSatellites,+ private val qthConverter: QthConverter,+ prefsManager: PrefsManager) : ViewModel() {private val dateNow = Date()@@ -71,12 +71,12 @@ class MapViewModel @Inject constructor(fun getSatMarkers(): LiveData<Map<Satellite, Position>> = _satMarkersval stationPosition = liveData {- emit(Position(gsp.latitude.toOsmLat(), gsp.longitude.toOsmLon()))+ emit(Position(gsp.lat.toOsmLat(), gsp.lon.toOsmLon()))}init {viewModelScope.launch {- val satellites = satelliteRepo.getSelectedSatellites()+ val satellites = getSelectedSatellites()if (satellites.isNotEmpty()) {filteredSats = satellitesselectedSat = satellites.first()@@ -171,18 +171,18 @@ class MapViewModel @Inject constructor(}private fun getSatFootprint(satPos: SatPos): Overlay {- val rangePoints = mutableListOf<GeoPoint>()- satPos.rangeCircle.forEach {+ val points = mutableListOf<GeoPoint>()+ satPos.getRangeCircle().forEach {val osmPos = Position(it.lat.toOsmLat(), it.lon.toOsmLon())- rangePoints.add(GeoPoint(osmPos.lat, osmPos.lon))+ points.add(GeoPoint(osmPos.lat, osmPos.lon))}return Polygon().apply {fillPaint.set(footprintPaint)outlinePaint.set(footprintPaint)try {- points = rangePoints+ this.points = points} catch (e: IllegalArgumentException) {- Timber.d("RangeCircle: ${satPos.rangeCircle}, RangePoints: $rangePoints")+ Timber.d("RangeCircle: ${satPos.getRangeCircle()}, RangePoints: $points")}}}diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesAdapter.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesAdapter.ktindex 3609396e..71f10542 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesAdapter.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesAdapter.kt@@ -23,9 +23,9 @@ import androidx.recyclerview.widget.AsyncListDifferimport androidx.recyclerview.widget.DiffUtilimport androidx.recyclerview.widget.RecyclerViewimport com.rtbishop.look4sat.R-import com.rtbishop.look4sat.data.model.SatPassimport com.rtbishop.look4sat.databinding.ItemPassGeoBindingimport com.rtbishop.look4sat.databinding.ItemPassLeoBinding+import com.rtbishop.look4sat.domain.predict4kotlin.SatPassimport java.text.SimpleDateFormatimport java.util.*diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesFragment.ktindex 1685d5a0..b88ab8cb 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesFragment.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesFragment.kt@@ -26,9 +26,9 @@ import androidx.navigation.fragment.findNavControllerimport androidx.recyclerview.widget.LinearLayoutManagerimport androidx.recyclerview.widget.SimpleItemAnimatorimport com.rtbishop.look4sat.R-import com.rtbishop.look4sat.data.model.Result-import com.rtbishop.look4sat.data.model.SatPass+import com.rtbishop.look4sat.framework.model.Resultimport com.rtbishop.look4sat.databinding.FragmentPassesBinding+import com.rtbishop.look4sat.domain.predict4kotlin.SatPassimport com.rtbishop.look4sat.utility.RecyclerDividerimport com.rtbishop.look4sat.utility.formatForTimerimport com.rtbishop.look4sat.utility.navigateSafediff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesViewModel.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesViewModel.ktindex 3302e640..51f3cf88 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesViewModel.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/passesScreen/PassesViewModel.kt@@ -21,10 +21,10 @@ import androidx.lifecycle.LiveDataimport androidx.lifecycle.MutableLiveDataimport androidx.lifecycle.ViewModelimport androidx.lifecycle.viewModelScope-import com.rtbishop.look4sat.data.model.Result-import com.rtbishop.look4sat.data.model.SatPass+import com.rtbishop.look4sat.framework.model.Resultimport com.rtbishop.look4sat.utility.PassesRepo-import com.rtbishop.look4sat.data.repository.SatelliteRepo+import com.rtbishop.look4sat.interactors.GetSelectedSatellites+import com.rtbishop.look4sat.domain.predict4kotlin.SatPassimport com.rtbishop.look4sat.utility.PrefsManagerimport dagger.hilt.android.lifecycle.HiltViewModelimport kotlinx.coroutines.*@@ -33,9 +33,9 @@ import javax.inject.Inject@HiltViewModelclass PassesViewModel @Inject constructor(- private val prefsManager: PrefsManager,- private val satelliteRepo: SatelliteRepo,- private val passesRepo: PassesRepo+ private val getSelectedSatellites: GetSelectedSatellites,+ private val passesRepo: PassesRepo,+ private val prefsManager: PrefsManager) : ViewModel() {private val _passes = MutableLiveData<Result<List<SatPass>>>(Result.InProgress)@@ -45,7 +45,7 @@ class PassesViewModel @Inject constructor(init {viewModelScope.launch {_passes.postValue(Result.InProgress)- passesRepo.triggerCalculation(satelliteRepo.getSelectedSatellites())+ passesRepo.triggerCalculation(getSelectedSatellites())}viewModelScope.launch {passesRepo.passes.collect { passes ->@@ -59,7 +59,7 @@ class PassesViewModel @Inject constructor(viewModelScope.launch {_passes.postValue(Result.InProgress)passesProcessing?.cancelAndJoin()- passesRepo.forceCalculation(satelliteRepo.getSelectedSatellites())+ passesRepo.forceCalculation(getSelectedSatellites())}}diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarFragment.ktindex 22ea35f1..abf5f2b7 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarFragment.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarFragment.kt@@ -25,8 +25,8 @@ import androidx.navigation.fragment.findNavControllerimport androidx.recyclerview.widget.LinearLayoutManagerimport androidx.recyclerview.widget.SimpleItemAnimatorimport com.rtbishop.look4sat.R-import com.rtbishop.look4sat.data.model.SatPassimport com.rtbishop.look4sat.databinding.FragmentPolarBinding+import com.rtbishop.look4sat.domain.predict4kotlin.SatPassimport com.rtbishop.look4sat.utility.RecyclerDividerimport com.rtbishop.look4sat.utility.formatForTimerimport com.rtbishop.look4sat.utility.navigateSafediff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarView.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarView.ktindex 0c9050ee..b8414be2 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarView.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarView.kt@@ -25,7 +25,7 @@ import android.graphics.Pathimport android.view.Viewimport androidx.core.content.ContextCompatimport com.rtbishop.look4sat.R-import com.rtbishop.look4sat.data.model.SatPass+import com.rtbishop.look4sat.domain.predict4kotlin.SatPassimport java.util.*import kotlin.math.cosimport kotlin.math.sindiff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarViewModel.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarViewModel.ktindex 0edf1bcb..5854a257 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarViewModel.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/PolarViewModel.kt@@ -18,11 +18,11 @@package com.rtbishop.look4sat.presentation.polarScreenimport androidx.lifecycle.*-import com.rtbishop.look4sat.data.model.SatPass-import com.rtbishop.look4sat.data.model.SatTransimport com.rtbishop.look4sat.utility.PassesRepo-import com.rtbishop.look4sat.data.repository.SatelliteRepoimport com.rtbishop.look4sat.di.IoDispatcher+import com.rtbishop.look4sat.domain.model.SatTrans+import com.rtbishop.look4sat.interactors.GetTransmittersForSat+import com.rtbishop.look4sat.domain.predict4kotlin.SatPassimport com.rtbishop.look4sat.utility.OrientationProviderimport com.rtbishop.look4sat.utility.PrefsManagerimport com.rtbishop.look4sat.utility.round@@ -39,7 +39,7 @@ class PolarViewModel @Inject constructor(private val orientationProvider: OrientationProvider,private val prefsManager: PrefsManager,private val passesRepo: PassesRepo,- private val satelliteRepo: SatelliteRepo,+ private val getTransmittersForSat: GetTransmittersForSat,@IoDispatcher private val ioDispatcher: CoroutineDispatcher) : ViewModel(), OrientationProvider.OrientationListener {@@ -98,7 +98,7 @@ class PolarViewModel @Inject constructor(private fun processTransmitters(satPass: SatPass) {viewModelScope.launch {- satelliteRepo.getSatTransmitters(satPass.catNum).collect { transList ->+ getTransmittersForSat(satPass.catNum).collect { transList ->while (isActive) {val timeNow = Date()val copiedList = transList.map { it.copy() }diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/TransAdapter.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/TransAdapter.ktindex b9185b3b..b8d53a10 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/TransAdapter.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/polarScreen/TransAdapter.kt@@ -23,8 +23,8 @@ import androidx.recyclerview.widget.AsyncListDifferimport androidx.recyclerview.widget.DiffUtilimport androidx.recyclerview.widget.RecyclerViewimport com.rtbishop.look4sat.R-import com.rtbishop.look4sat.data.model.SatTransimport com.rtbishop.look4sat.databinding.ItemTransBinding+import com.rtbishop.look4sat.domain.model.SatTransimport java.util.*class TransAdapter : RecyclerView.Adapter<TransAdapter.TransHolder>() {diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/prefsScreen/PrefsFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/prefsScreen/PrefsFragment.ktindex 166f42bc..623e70ed 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/prefsScreen/PrefsFragment.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/prefsScreen/PrefsFragment.kt@@ -103,7 +103,7 @@ class PrefsFragment : PreferenceFragmentCompat() {private fun setPositionFromQth(qthString: String): Boolean {qthConverter.qthToLocation(qthString)?.let { gsp ->- prefsManager.setStationPosition(gsp.latitude, gsp.longitude, gsp.heightAMSL)+ prefsManager.setStationPosition(gsp.lat, gsp.lon, gsp.alt)showSnack(getString(R.string.pref_pos_success))return true}diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/sourcesDialog/SourcesAdapter.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/sourcesDialog/SourcesAdapter.ktindex d6a5d785..23d5eb44 100644--- a/app/src/main/java/com/rtbishop/look4sat/presentation/sourcesDialog/SourcesAdapter.kt+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/sourcesDialog/SourcesAdapter.kt@@ -21,8 +21,8 @@ import android.view.LayoutInflaterimport android.view.ViewGroupimport androidx.core.widget.doOnTextChangedimport androidx.recyclerview.widget.RecyclerView-import com.rtbishop.look4sat.data.model.TleSourceimport com.rtbishop.look4sat.databinding.ItemTleSourceBinding+import com.rtbishop.look4sat.framework.model.TleSourceclass SourcesAdapter(private val sources: MutableList<TleSource> = mutableListOf()) :RecyclerView.Adapter<SourcesAdapter.TleSourceHolder>() {diff --git a/app/src/main/java/com/rtbishop/look4sat/utility/Extensions.kt b/app/src/main/java/com/rtbishop/look4sat/utility/Extensions.ktindex 5dde77fb..faea0b3e 100644--- a/app/src/main/java/com/rtbishop/look4sat/utility/Extensions.kt+++ b/app/src/main/java/com/rtbishop/look4sat/utility/Extensions.kt@@ -26,8 +26,6 @@ import androidx.navigation.NavControllerimport androidx.navigation.NavOptionsimport androidx.navigation.Navigatorimport androidx.navigation.fragment.findNavController-import com.github.amsacode.predict4java.GroundStationPosition-import com.github.amsacode.predict4java.Satelliteimport java.util.concurrent.TimeUnitimport kotlin.math.maximport kotlin.math.min@@ -64,10 +62,6 @@ fun Double.getOrbitalVelocity(): Double {return sqrt(earthG * earthM / radius) / 1000}-fun Satellite.getPredictor(stationPosition: GroundStationPosition): PassPredictor {- return PassPredictor(this, stationPosition)-}-fun NavController.navigateSafe(@IdRes resId: Int,args: Bundle? = null,diff --git a/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt b/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.ktdeleted file mode 100644index cc7c48e7..00000000--- a/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt+++ /dev/null@@ -1,184 +0,0 @@-/*- * Look4Sat. Amateur radio satellite tracker and pass predictor.- * Copyright (C) 2019-2021 Arty Bishop ([email protected])- *- * 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.utility--import com.github.amsacode.predict4java.GroundStationPosition-import com.github.amsacode.predict4java.SatPos-import com.github.amsacode.predict4java.Satellite-import com.rtbishop.look4sat.data.model.SatPass-import java.util.*--class PassPredictor(private val satellite: Satellite, private val qth: GroundStationPosition) {-- private val oneQuarterOrbitMin = (24.0 * 60.0 / satellite.tle.meanmo / 4.0).toInt()- private val speedOfLight = 2.99792458E8-- fun getDownlinkFreq(freq: Long, date: Date): Long {- val rangeRate = getSatPos(date).rangeRate- return (freq.toDouble() * (speedOfLight - rangeRate * 1000.0) / speedOfLight).toLong()- }-- fun getUplinkFreq(freq: Long, date: Date): Long {- val rangeRate = getSatPos(date).rangeRate- return (freq.toDouble() * (speedOfLight + rangeRate * 1000.0) / speedOfLight).toLong()- }-- fun getSatPos(date: Date): SatPos {- return satellite.getPosition(qth, date)- }-- fun getPositions(refDate: Date, stepSec: Int, minBefore: Int, orbits: Double): List<SatPos> {- val positions = mutableListOf<SatPos>()- val orbitalPeriod = 24 * 60 / satellite.tle.meanmo- val endDate = Date(refDate.time + (orbitalPeriod * orbits * 60L * 1000L).toLong())- val startDate = Date(refDate.time - minBefore * 60L * 1000L)- var currentDate = startDate- while (currentDate.before(endDate)) {- positions.add(getSatPos(currentDate))- currentDate = Date(currentDate.time + stepSec * 1000)- }- return positions- }-- fun getPasses(refDate: Date, hoursAhead: Int, windBack: Boolean): List<SatPass> {- val passes = mutableListOf<SatPass>()- val endDate = Date(refDate.time + hoursAhead * 60L * 60L * 1000L)- var startDate = refDate- var shouldWindBack = windBack- var lastAosDate: Date- var count = 0- if (satellite.willBeSeen(qth)) {- if (satellite.tle.isDeepspace) {- passes.add(nextDeepSpacePass(refDate))- } else {- do {- if (count > 0) shouldWindBack = false- val pass = nextNearEarthPass(startDate, shouldWindBack)- lastAosDate = pass.aosDate- passes.add(pass)- startDate =- Date(pass.losDate.time + (oneQuarterOrbitMin * 3) * 60L * 1000L)- count++- } while (lastAosDate < endDate)- }- }- return passes- }-- private fun nextDeepSpacePass(refDate: Date): SatPass {- val satPos = getSatPos(refDate)- val id = satellite.tle.catnum- val name = satellite.tle.name- val isDeep = satellite.tle.isDeepspace- val aos = Date(refDate.time - 24 * 60L * 60L * 1000L).time- val los = Date(refDate.time + 24 * 60L * 60L * 1000L).time- val tca = Date((aos + los) / 2).time- val az = Math.toDegrees(satPos.azimuth)- val elev = Math.toDegrees(satPos.elevation)- val alt = satPos.altitude- return SatPass(id, name, isDeep, aos, az, los, az, tca, az, alt, elev, this)- }-- private fun nextNearEarthPass(refDate: Date, windBack: Boolean = false): SatPass {- val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")).apply {- clear()- timeInMillis = refDate.time- }- val id = satellite.tle.catnum- val name = satellite.tle.name- val isDeep = satellite.tle.isDeepspace-- var elevation: Double- var maxElevation = 0.0- var alt = 0.0- var tcaAz = 0.0-- // wind back time 1/4 of an orbit- if (windBack) calendar.add(Calendar.MINUTE, -oneQuarterOrbitMin)- var satPos = getSatPos(calendar.time)-- if (satPos.elevation > 0.0) {- // move forward in 30 second intervals until the sat goes below the horizon- do {- calendar.add(Calendar.SECOND, 30)- satPos = getSatPos(calendar.time)- } while (satPos.elevation > 0.0)- // move forward 3/4 of an orbit- calendar.add(Calendar.MINUTE, oneQuarterOrbitMin * 3)- }-- // find the next time sat comes above the horizon- do {- calendar.add(Calendar.SECOND, 60)- satPos = getSatPos(calendar.time)- elevation = satPos.elevation- if (elevation > maxElevation) {- maxElevation = elevation- alt = satPos.altitude- tcaAz = Math.toDegrees(satPos.azimuth)- }- } while (satPos.elevation < 0.0)-- // refine to 3 seconds- calendar.add(Calendar.SECOND, -60)- do {- calendar.add(Calendar.SECOND, 3)- satPos = getSatPos(calendar.time)- elevation = satPos.elevation- if (elevation > maxElevation) {- maxElevation = elevation- alt = satPos.altitude- tcaAz = Math.toDegrees(satPos.azimuth)- }- } while (satPos.elevation < 0.0)-- val aos = satPos.time.time- val aosAz = Math.toDegrees(satPos.azimuth)-- // find when sat goes below- do {- calendar.add(Calendar.SECOND, 30)- satPos = getSatPos(calendar.time)- elevation = satPos.elevation- if (elevation > maxElevation) {- maxElevation = elevation- alt = satPos.altitude- tcaAz = Math.toDegrees(satPos.azimuth)- }- } while (satPos.elevation > 0.0)-- // refine to 3 seconds- calendar.add(Calendar.SECOND, -30)- do {- calendar.add(Calendar.SECOND, 3)- satPos = getSatPos(calendar.time)- elevation = satPos.elevation- if (elevation > maxElevation) {- maxElevation = elevation- alt = satPos.altitude- tcaAz = Math.toDegrees(satPos.azimuth)- }- } while (satPos.elevation > 0.0)-- val los = satPos.time.time- val losAz = Math.toDegrees(satPos.azimuth)- val tca = Date((aos + los) / 2).time- val elev = Math.toDegrees(maxElevation)- return SatPass(id, name, isDeep, aos, aosAz, los, losAz, tca, tcaAz, alt, elev, this)- }-}diff --git a/app/src/main/java/com/rtbishop/look4sat/utility/PassesRepo.kt b/app/src/main/java/com/rtbishop/look4sat/utility/PassesRepo.ktindex 067b05bf..3ae36217 100644--- a/app/src/main/java/com/rtbishop/look4sat/utility/PassesRepo.kt+++ b/app/src/main/java/com/rtbishop/look4sat/utility/PassesRepo.kt@@ -17,9 +17,9 @@*/package com.rtbishop.look4sat.utility-import com.github.amsacode.predict4java.Satellite-import com.rtbishop.look4sat.data.model.SatPassimport com.rtbishop.look4sat.di.DefaultDispatcher+import com.rtbishop.look4sat.domain.predict4kotlin.SatPass+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport kotlinx.coroutines.CoroutineDispatcherimport kotlinx.coroutines.flow.MutableSharedFlowimport kotlinx.coroutines.flow.SharedFlowdiff --git a/app/src/main/java/com/rtbishop/look4sat/utility/PrefsManager.kt b/app/src/main/java/com/rtbishop/look4sat/utility/PrefsManager.ktindex 22a923d1..e6064a17 100644--- a/app/src/main/java/com/rtbishop/look4sat/utility/PrefsManager.kt+++ b/app/src/main/java/com/rtbishop/look4sat/utility/PrefsManager.kt@@ -20,8 +20,8 @@ package com.rtbishop.look4sat.utilityimport android.content.SharedPreferencesimport android.hardware.GeomagneticFieldimport androidx.core.content.edit-import com.github.amsacode.predict4java.GroundStationPosition-import com.rtbishop.look4sat.data.model.TleSource+import com.rtbishop.look4sat.framework.model.TleSource+import com.rtbishop.look4sat.domain.predict4kotlin.GroundPosimport com.squareup.moshi.Moshiimport com.squareup.moshi.Typesimport javax.inject.Inject@@ -60,12 +60,12 @@ class PrefsManager @Inject constructor(val preferences: SharedPreferences, moshireturn preferences.getInt(keyMinElevation, 16).toDouble()}- fun getStationPosition(): GroundStationPosition {+ fun getStationPosition(): GroundPos {val defaultGSP = "0.0"val latitude = preferences.getString(keyLatitude, null) ?: defaultGSPval longitude = preferences.getString(keyLongitude, null) ?: defaultGSPval altitude = preferences.getString(keyAltitude, null) ?: defaultGSP- return GroundStationPosition(latitude.toDouble(), longitude.toDouble(), altitude.toDouble())+ return GroundPos(latitude.toDouble(), longitude.toDouble(), altitude.toDouble())}fun setStationPosition(latitude: Double, longitude: Double, altitude: Double) {@@ -78,9 +78,9 @@ class PrefsManager @Inject constructor(val preferences: SharedPreferences, moshifun getMagDeclination(): Float {val stationPosition = getStationPosition()- val lat = stationPosition.latitude.toFloat()- val lon = stationPosition.longitude.toFloat()- val alt = stationPosition.heightAMSL.toFloat()+ val lat = stationPosition.lat.toFloat()+ val lon = stationPosition.lon.toFloat()+ val alt = stationPosition.alt.toFloat()return GeomagneticField(lat, lon, alt, System.currentTimeMillis()).declination}diff --git a/app/src/main/java/com/rtbishop/look4sat/utility/QthConverter.kt b/app/src/main/java/com/rtbishop/look4sat/utility/QthConverter.ktindex 5c755b05..5ec1c26d 100644--- a/app/src/main/java/com/rtbishop/look4sat/utility/QthConverter.kt+++ b/app/src/main/java/com/rtbishop/look4sat/utility/QthConverter.kt@@ -17,12 +17,12 @@*/package com.rtbishop.look4sat.utility-import com.github.amsacode.predict4java.GroundStationPosition+import com.rtbishop.look4sat.domain.predict4kotlin.GroundPosimport javax.inject.Injectclass QthConverter @Inject constructor() {- fun qthToLocation(qthString: String): GroundStationPosition? {+ fun qthToLocation(qthString: String): GroundPos? {val trimmedQth = qthString.take(6)if (!isValidQTH(trimmedQth)) return nullval lonFirst = (trimmedQth[0].toUpperCase().toInt() - 65) * 20@@ -33,7 +33,7 @@ class QthConverter @Inject constructor() {val latThird = (((trimmedQth[5].toLowerCase().toInt() - 97) / 24.0) + (1.0 / 48.0)) - 90val longitude = (lonFirst + lonSecond + lonThird).round(4)val latitude = (latFirst + latSecond + latThird).round(4)- return GroundStationPosition(latitude, longitude, 0.0)+ return GroundPos(latitude, longitude, 0.0)}fun locationToQTH(lat: Double, lon: Double): String? {diff --git a/build.gradle b/build.gradleindex a2b6403a..6725db09 100644--- a/build.gradle+++ b/build.gradle@@ -2,7 +2,7 @@ buildscript {ext {gradle_version = '4.1.3'kotlin_version = '1.4.32'- coroutines_version = '1.4.1'+ coroutines_version = '1.4.3'material_version = '1.3.0'constraint_layout_version = '2.0.4'lifecycle_version = '2.3.1'@@ -11,7 +11,6 @@ buildscript {room_version = '2.3.0'hilt_version = '2.33-beta'retrofit_version = '2.9.0'- predict4java_version = '1.3.1'osmdroid_version = '6.1.10'timber_version = '4.7.1'junit_version = '4.13.2'diff --git a/core/build.gradle b/core/build.gradleindex d217f9bb..a709f96d 100644--- a/core/build.gradle+++ b/core/build.gradle@@ -11,4 +11,7 @@ java {dependencies {implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"-}\ No newline at end of file++ testImplementation "junit:junit:$junit_version"+ testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_test_version"+}diff --git a/core/src/main/java/com/rtbishop/look4sat/data/DefaultSatelliteRepo.kt b/core/src/main/java/com/rtbishop/look4sat/data/DefaultSatelliteRepo.ktindex 4c4063af..83b702ea 100644--- a/core/src/main/java/com/rtbishop/look4sat/data/DefaultSatelliteRepo.kt+++ b/core/src/main/java/com/rtbishop/look4sat/data/DefaultSatelliteRepo.kt@@ -4,7 +4,7 @@ import com.rtbishop.look4sat.domain.SatelliteRepoimport com.rtbishop.look4sat.domain.model.SatEntryimport com.rtbishop.look4sat.domain.model.SatItemimport com.rtbishop.look4sat.domain.model.SatTrans-import com.rtbishop.look4sat.predict4kotlin.Satellite+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport kotlinx.coroutines.CoroutineDispatcherimport kotlinx.coroutines.coroutineScopeimport kotlinx.coroutines.flow.Flow@@ -32,15 +32,13 @@ class DefaultSatelliteRepo(}override suspend fun importDataFromFile(stream: InputStream) = withContext(ioDispatcher) {- val entries = mutableListOf<SatEntry>()- val tleList = Satellite.importTLE(stream)- tleList.forEach { tle -> entries.add(SatEntry(tle)) }+ val entries = Satellite.importTLE(stream).map { tle -> SatEntry(tle) }localSource.updateEntries(entries)}override suspend fun importDataFromWeb(sources: List<String>) {coroutineScope {- launch {+ launch(ioDispatcher) {val entries = mutableListOf<SatEntry>()val streams = mutableListOf<InputStream>()sources.forEach { source ->@@ -59,7 +57,7 @@ class DefaultSatelliteRepo(}localSource.updateEntries(entries)}- launch {+ launch(ioDispatcher) {val transmitters = remoteSource.fetchTransmitters().filter { it.isAlive }localSource.updateTransmitters(transmitters)}diff --git a/core/src/main/java/com/rtbishop/look4sat/data/LocalDataSource.kt b/core/src/main/java/com/rtbishop/look4sat/data/LocalDataSource.ktindex 2afb6876..b481ebc6 100644--- a/core/src/main/java/com/rtbishop/look4sat/data/LocalDataSource.kt+++ b/core/src/main/java/com/rtbishop/look4sat/data/LocalDataSource.kt@@ -3,7 +3,7 @@ package com.rtbishop.look4sat.dataimport com.rtbishop.look4sat.domain.model.SatEntryimport com.rtbishop.look4sat.domain.model.SatItemimport com.rtbishop.look4sat.domain.model.SatTrans-import com.rtbishop.look4sat.predict4kotlin.Satellite+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport kotlinx.coroutines.flow.Flowinterface LocalDataSource {diff --git a/core/src/main/java/com/rtbishop/look4sat/domain/SatelliteRepo.kt b/core/src/main/java/com/rtbishop/look4sat/domain/SatelliteRepo.ktindex ad81afb7..44cf4945 100644--- a/core/src/main/java/com/rtbishop/look4sat/domain/SatelliteRepo.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/SatelliteRepo.kt@@ -2,7 +2,7 @@ package com.rtbishop.look4sat.domainimport com.rtbishop.look4sat.domain.model.SatItemimport com.rtbishop.look4sat.domain.model.SatTrans-import com.rtbishop.look4sat.predict4kotlin.Satellite+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteimport kotlinx.coroutines.flow.Flowimport java.io.InputStream@@ -19,4 +19,4 @@ interface SatelliteRepo {suspend fun importDataFromWeb(sources: List<String>)suspend fun updateEntriesSelection(catNums: List<Int>, isSelected: Boolean)-}\ No newline at end of file+}diff --git a/core/src/main/java/com/rtbishop/look4sat/domain/model/SatEntry.kt b/core/src/main/java/com/rtbishop/look4sat/domain/model/SatEntry.ktindex e92e1462..1f16a42e 100644--- a/core/src/main/java/com/rtbishop/look4sat/domain/model/SatEntry.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/model/SatEntry.kt@@ -1,6 +1,6 @@package com.rtbishop.look4sat.domain.model-import com.rtbishop.look4sat.predict4kotlin.TLE+import com.rtbishop.look4sat.domain.predict4kotlin.TLEdata class SatEntry(val tle: TLE,diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/DeepSpaceSat.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/DeepSpaceSat.ktsimilarity index 99%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/DeepSpaceSat.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/DeepSpaceSat.ktindex c7f21e57..a5067911 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/DeepSpaceSat.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/DeepSpaceSat.kt@@ -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.predict4kotlinimport kotlin.math.*diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/GroundPos.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/GroundPos.ktsimilarity index 94%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/GroundPos.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/GroundPos.ktindex 44cfeb51..1631aa43 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/GroundPos.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/GroundPos.kt@@ -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.predict4kotlindata class GroundPos(val lat: Double, val lon: Double, val alt: Double, val name: String = "base")diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/NearEarthSat.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/NearEarthSat.ktsimilarity index 99%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/NearEarthSat.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/NearEarthSat.ktindex 3bc53450..9438f159 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/NearEarthSat.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/NearEarthSat.kt@@ -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.predict4kotlinimport kotlin.math.*diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/PassPredictor.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/PassPredictor.ktsimilarity index 99%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/PassPredictor.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/PassPredictor.ktindex 423a09ae..0064a7c0 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/PassPredictor.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/PassPredictor.kt@@ -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.predict4kotlinimport java.util.*diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/Position.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/Position.ktsimilarity index 94%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/Position.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/Position.ktindex 3f5af4a7..b12f3a94 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/Position.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/Position.kt@@ -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.predict4kotlindata class Position(val lat: Double, val lon: Double)diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/SatPass.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/SatPass.ktsimilarity index 96%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/SatPass.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/SatPass.ktindex 61ea418a..36809f9b 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/SatPass.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/SatPass.kt@@ -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.predict4kotlinimport java.util.*diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/SatPos.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/SatPos.ktsimilarity index 98%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/SatPos.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/SatPos.ktindex 00bba065..aed3b95f 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/SatPos.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/SatPos.kt@@ -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.predict4kotlinimport java.util.*import kotlin.math.*diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/Satellite.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/Satellite.ktsimilarity index 99%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/Satellite.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/Satellite.ktindex 5a65293f..7aa1b187 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/Satellite.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/Satellite.kt@@ -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.predict4kotlinimport java.io.InputStreamimport java.util.*diff --git a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/TLE.kt b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/TLE.ktsimilarity index 96%rename from core/src/main/java/com/rtbishop/look4sat/predict4kotlin/TLE.ktrename to core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/TLE.ktindex 0dd2eee1..a3c5e5a8 100644--- a/core/src/main/java/com/rtbishop/look4sat/predict4kotlin/TLE.kt+++ b/core/src/main/java/com/rtbishop/look4sat/domain/predict4kotlin/TLE.kt@@ -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.predict4kotlindata class TLE(val name: String,diff --git a/core/src/main/java/com/rtbishop/look4sat/interactors/GetSatItems.kt b/core/src/main/java/com/rtbishop/look4sat/interactors/GetSatItems.ktindex 6d39f7cf..6a053de9 100644--- a/core/src/main/java/com/rtbishop/look4sat/interactors/GetSatItems.kt+++ b/core/src/main/java/com/rtbishop/look4sat/interactors/GetSatItems.kt@@ -9,4 +9,4 @@ class GetSatItems(private val satelliteRepo: SatelliteRepo) {operator fun invoke(): Flow<List<SatItem>> {return satelliteRepo.getSatItems()}-}\ No newline at end of file+}diff --git a/core/src/main/java/com/rtbishop/look4sat/interactors/GetSelectedSatellites.kt b/core/src/main/java/com/rtbishop/look4sat/interactors/GetSelectedSatellites.ktindex d789b136..58638138 100644--- a/core/src/main/java/com/rtbishop/look4sat/interactors/GetSelectedSatellites.kt+++ b/core/src/main/java/com/rtbishop/look4sat/interactors/GetSelectedSatellites.kt@@ -1,11 +1,11 @@package com.rtbishop.look4sat.interactorsimport com.rtbishop.look4sat.domain.SatelliteRepo-import com.rtbishop.look4sat.predict4kotlin.Satellite+import com.rtbishop.look4sat.domain.predict4kotlin.Satelliteclass GetSelectedSatellites(private val satelliteRepo: SatelliteRepo) {suspend operator fun invoke(): List<Satellite> {return satelliteRepo.getSelectedSatellites()}-}\ No newline at end of file+}diff --git a/core/src/main/java/com/rtbishop/look4sat/interactors/GetTransmittersForSat.kt b/core/src/main/java/com/rtbishop/look4sat/interactors/GetTransmittersForSat.ktindex eac8da22..87862853 100644--- a/core/src/main/java/com/rtbishop/look4sat/interactors/GetTransmittersForSat.kt+++ b/core/src/main/java/com/rtbishop/look4sat/interactors/GetTransmittersForSat.kt@@ -9,4 +9,4 @@ class GetTransmittersForSat(private val satelliteRepo: SatelliteRepo) {operator fun invoke(catNum: Int): Flow<List<SatTrans>> {return satelliteRepo.getTransmittersForSat(catNum)}-}\ No newline at end of file+}diff --git a/core/src/main/java/com/rtbishop/look4sat/interactors/ImportDataFromFile.kt b/core/src/main/java/com/rtbishop/look4sat/interactors/ImportDataFromFile.ktindex ec5adf0f..62ed17c7 100644--- a/core/src/main/java/com/rtbishop/look4sat/interactors/ImportDataFromFile.kt+++ b/core/src/main/java/com/rtbishop/look4sat/interactors/ImportDataFromFile.kt@@ -8,4 +8,4 @@ class ImportDataFromFile(private val satelliteRepo: SatelliteRepo) {suspend operator fun invoke(stream: InputStream) {satelliteRepo.importDataFromFile(stream)}-}\ No newline at end of file+}diff --git a/core/src/main/java/com/rtbishop/look4sat/interactors/ImportDataFromWeb.kt b/core/src/main/java/com/rtbishop/look4sat/interactors/ImportDataFromWeb.ktindex d9cfa225..9e19afa0 100644--- a/core/src/main/java/com/rtbishop/look4sat/interactors/ImportDataFromWeb.kt+++ b/core/src/main/java/com/rtbishop/look4sat/interactors/ImportDataFromWeb.kt@@ -7,4 +7,4 @@ class ImportDataFromWeb(private val satelliteRepo: SatelliteRepo) {suspend operator fun invoke(sources: List<String>) {satelliteRepo.importDataFromWeb(sources)}-}\ No newline at end of file+}diff --git a/core/src/main/java/com/rtbishop/look4sat/interactors/UpdateEntriesSelection.kt b/core/src/main/java/com/rtbishop/look4sat/interactors/UpdateEntriesSelection.ktindex f453060a..33dce2fb 100644--- a/core/src/main/java/com/rtbishop/look4sat/interactors/UpdateEntriesSelection.kt+++ b/core/src/main/java/com/rtbishop/look4sat/interactors/UpdateEntriesSelection.kt@@ -7,4 +7,4 @@ class UpdateEntriesSelection(private val satelliteRepo: SatelliteRepo) {suspend operator fun invoke(catNums: List<Int>, isSelected: Boolean) {satelliteRepo.updateEntriesSelection(catNums, isSelected)}-}\ No newline at end of file+}diff --git a/gradle.properties b/gradle.propertiesindex 13cac6cf..667087ef 100644--- a/gradle.properties+++ b/gradle.properties@@ -18,4 +18,4 @@ android.useAndroidX=true# Automatically convert third-party libraries to use AndroidXandroid.enableJetifier=true# Kotlin code style for this project: "official" or "obsolete":-kotlin.code.style=official\ No newline at end of file+kotlin.code.style=officialdiff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.propertiesindex b985a72f..0fb0dad1 100644--- a/gradle/wrapper/gradle-wrapper.properties+++ b/gradle/wrapper/gradle-wrapper.properties@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/dists-distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip