v3.1.4 - Fixed leap year bug, various other minor fixes

pull/137/head v3.1.4
Arty Bishop 2024-03-09 13:23:47 +00:00
rodzic b1562b4796
commit 04da45e278
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 5C71CFDC37AD73CC
17 zmienionych plików z 123 dodań i 77 usunięć

Wyświetl plik

@ -3,20 +3,20 @@ name: Look4Sat CI
on:
push:
tags:
- '*'
- v**
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout latest commit
uses: actions/checkout@v3
- name: Checkout Latest Commit
uses: actions/checkout@v4
- name: Setup java environment
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
- name: Assemble APK and Bundle
run: |
@ -34,7 +34,7 @@ jobs:
alias: ${{ secrets.KEY_ALIAS }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: "33.0.0"
BUILD_TOOLS_VERSION: "34.0.0"
- name: Sign Bundle
uses: r0adkll/sign-android-release@v1
@ -46,25 +46,25 @@ jobs:
alias: ${{ secrets.KEY_ALIAS }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: "33.0.0"
BUILD_TOOLS_VERSION: "34.0.0"
- name: Rename APK
- name: Rename APK and Bundle
run: |
mv ${{steps.sign_apk.outputs.signedReleaseFile}} app/build/outputs/apk/release/look4sat.apk
mv ${{steps.sign_bundle.outputs.signedReleaseFile}} app/build/outputs/apk/release/look4sat.aab
- name: Deploy Bundle to Play Store
uses: r0adkll/upload-google-play@v1.0.17
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{secrets.SERVICE_ACCOUNT_JSON}}
packageName: com.rtbishop.look4sat
releaseFiles: app/build/outputs/apk/release/look4sat.aab
track: production
mappingFile: app/build/outputs/mapping/release/mapping.txt
whatsNewDirectory: fastlane/metadata/android/en-US/whatsnew
releaseFiles: ${{steps.sign_bundle.outputs.signedReleaseFile}}
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: app/build/outputs/apk/release/look4sat.apk
artifacts: "app/build/outputs/apk/release/look4sat.apk,app/build/outputs/apk/release/look4sat.aab"
bodyFile: fastlane/metadata/android/en-US/whatsnew/whatsnew-en-US
token: ${{ secrets.RELEASE_TOKEN }}

Wyświetl plik

@ -7,16 +7,14 @@ plugins {
}
android {
compileSdkVersion 33
buildToolsVersion '33.0.0'
namespace 'com.rtbishop.look4sat'
compileSdk 34
defaultConfig {
applicationId "com.rtbishop.look4sat"
minSdk 21
targetSdk 33
versionCode 313
versionName '3.1.3'
targetSdk 34
versionCode 314
versionName '3.1.4'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -43,11 +41,11 @@ android {
kotlinCompilerExtensionVersion compose_compiler_version
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
}
testOptions {
animationsDisabled true
@ -56,7 +54,7 @@ android {
}
kotlin {
jvmToolchain(11)
jvmToolchain(17)
}
dependencies {

11
app/proguard-rules.pro vendored 100644
Wyświetl plik

@ -0,0 +1,11 @@
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE

Wyświetl plik

@ -17,10 +17,10 @@
*/
package com.rtbishop.look4sat.framework.data
import com.rtbishop.look4sat.domain.data.ILocalRadioSource
import com.rtbishop.look4sat.framework.data.dao.RadiosDao
import com.rtbishop.look4sat.domain.model.SatRadio as DomainRadio
import com.rtbishop.look4sat.framework.model.SatRadio as FrameworkRadio
import com.rtbishop.look4sat.domain.data.ILocalRadioSource
import com.rtbishop.look4sat.framework.data.dao.RadiosDao
class LocalRadioSource(private val radiosDao: RadiosDao) : ILocalRadioSource {
@ -31,6 +31,7 @@ class LocalRadioSource(private val radiosDao: RadiosDao) : ILocalRadioSource {
}
override suspend fun insertRadios(radios: List<DomainRadio>) {
radiosDao.deleteRadios()
radiosDao.insertRadios(radios.toFrameworkRadios())
}

Wyświetl plik

@ -28,7 +28,12 @@ import com.rtbishop.look4sat.domain.data.DataRepository
import com.rtbishop.look4sat.domain.predict.SatelliteManager
import com.rtbishop.look4sat.framework.LocationManager
import com.rtbishop.look4sat.framework.SettingsManager
import com.rtbishop.look4sat.framework.data.*
import com.rtbishop.look4sat.framework.data.FileDataSource
import com.rtbishop.look4sat.framework.data.LocalDatabase
import com.rtbishop.look4sat.framework.data.LocalEntrySource
import com.rtbishop.look4sat.framework.data.LocalRadioSource
import com.rtbishop.look4sat.framework.data.MIGRATION_1_2
import com.rtbishop.look4sat.framework.data.RemoteDataSource
import com.rtbishop.look4sat.presentation.radarScreen.BTReporter
import com.rtbishop.look4sat.utility.DataParser
import com.rtbishop.look4sat.utility.DataReporter
@ -37,11 +42,11 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import okhttp3.OkHttpClient
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)

Wyświetl plik

@ -19,7 +19,11 @@ package com.rtbishop.look4sat.presentation.radarScreen
import android.hardware.GeomagneticField
import android.util.Log
import androidx.lifecycle.*
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.liveData
import androidx.lifecycle.viewModelScope
import com.rtbishop.look4sat.domain.IDataRepository
import com.rtbishop.look4sat.domain.ISatelliteManager
import com.rtbishop.look4sat.domain.ISettingsManager
@ -33,10 +37,10 @@ import com.rtbishop.look4sat.utility.DataReporter
import com.rtbishop.look4sat.utility.round
import com.rtbishop.look4sat.utility.toDegrees
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import javax.inject.Inject
@HiltViewModel
class RadarViewModel @Inject constructor(
@ -107,8 +111,8 @@ class RadarViewModel @Inject constructor(
if (settings.getRotatorEnabled()) {
val server = settings.getRotatorServer()
val port = settings.getRotatorPort().toInt()
val azimuth = satPos.azimuth.toDegrees().round(1)
val elevation = satPos.elevation.toDegrees().round(1)
val azimuth = satPos.azimuth.toDegrees().round(2)
val elevation = satPos.elevation.toDegrees().round(2)
reporter.reportRotation(server, port, azimuth, elevation)
}
_passData.postValue(RadarData(satPos, track))

Wyświetl plik

@ -69,12 +69,12 @@
<string name="pass_satName">%s</string>
<string name="pass_satId">Id:%d</string>
<string name="pass_aosAz">AOS - %.1f°</string>
<string name="pass_elevation">Elevation: %.1f°</string>
<string name="pass_elevation">ELEV: %.1f°</string>
<string name="pass_los">%.1f° - LOS</string>
<string name="pass_altitude">Altitude: %.0f km</string>
<string name="pass_altitude">ALT: %.0f km</string>
<string name="pass_placeholder"> - - : - - </string>
<string name="pass_startTime">HH:mm:ss - EEE</string>
<string name="pass_endTime">EEE - HH:mm:ss</string>
<string name="pass_startTime">HH:mm:ss - MMM dd</string>
<string name="pass_endTime">dd MMM - HH:mm:ss</string>
<string name="radar_az_text">Azimuth</string>
<string name="radar_az_value">%.1f°</string>

Wyświetl plik

@ -3,7 +3,7 @@ plugins {
}
kotlin {
jvmToolchain(11)
jvmToolchain(17)
}
dependencies {

Wyświetl plik

@ -21,7 +21,7 @@ import java.io.InputStream
interface IRemoteDataSource {
val radioApi: String get() = "https://db.satnogs.org/api/transmitters/?format=json"
val radioApi: String get() = "https://db.satnogs.org/api/transmitters/?format=json&status=active"
suspend fun getDataStream(url: String): InputStream?
}

Wyświetl plik

@ -19,48 +19,46 @@ package com.rtbishop.look4sat.utility
import com.rtbishop.look4sat.domain.model.SatRadio
import com.rtbishop.look4sat.domain.predict.OrbitalData
import java.io.InputStream
import kotlin.math.pow
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import org.json.JSONArray
import org.json.JSONObject
import java.io.InputStream
import kotlin.math.pow
class DataParser(private val defaultDispatcher: CoroutineDispatcher) {
suspend fun parseCSVStream(csvStream: InputStream): List<OrbitalData> =
withContext(defaultDispatcher) {
val parsedItems = mutableListOf<OrbitalData>()
csvStream.bufferedReader().useLines { lines ->
lines.forEachIndexed { index, line ->
if (index != 0) {
val values = line.split(",")
parseCSV(values)?.let { tle -> parsedItems.add(tle) }
}
suspend fun parseCSVStream(csvStream: InputStream): List<OrbitalData> = withContext(defaultDispatcher) {
val parsedItems = mutableListOf<OrbitalData>()
csvStream.bufferedReader().useLines { lines ->
lines.forEachIndexed { index, line ->
if (index != 0) {
val values = line.split(",")
parseCSV(values)?.let { tle -> parsedItems.add(tle) }
}
}
return@withContext parsedItems
}
return@withContext parsedItems
}
suspend fun parseTLEStream(tleStream: InputStream): List<OrbitalData> =
withContext(defaultDispatcher) {
val tleStrings = mutableListOf(String(), String(), String())
val parsedItems = mutableListOf<OrbitalData>()
var lineIndex = 0
tleStream.bufferedReader().forEachLine { line ->
tleStrings[lineIndex] = line
if (lineIndex < 2) {
lineIndex++
} else {
val isLineOneValid = tleStrings[1].substring(0, 1) == "1"
val isLineTwoValid = tleStrings[2].substring(0, 1) == "2"
if (!isLineOneValid && !isLineTwoValid) return@forEachLine
parseTLE(tleStrings)?.let { tle -> parsedItems.add(tle) }
lineIndex = 0
}
suspend fun parseTLEStream(tleStream: InputStream): List<OrbitalData> = withContext(defaultDispatcher) {
val tleStrings = mutableListOf(String(), String(), String())
val parsedItems = mutableListOf<OrbitalData>()
var lineIndex = 0
tleStream.bufferedReader().forEachLine { line ->
tleStrings[lineIndex] = line
if (lineIndex < 2) {
lineIndex++
} else {
val isLineOneValid = tleStrings[1].substring(0, 1) == "1"
val isLineTwoValid = tleStrings[2].substring(0, 1) == "2"
if (!isLineOneValid && !isLineTwoValid) return@forEachLine
parseTLE(tleStrings)?.let { tle -> parsedItems.add(tle) }
lineIndex = 0
}
return@withContext parsedItems
}
return@withContext parsedItems
}
suspend fun parseJSONStream(jsonStream: InputStream): List<SatRadio> {
return withContext(defaultDispatcher) {
@ -78,6 +76,10 @@ class DataParser(private val defaultDispatcher: CoroutineDispatcher) {
}
}
fun isLeapYear(year: Int): Boolean {
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)
}
private fun parseCSV(values: List<String>): OrbitalData? {
try {
val name = values[0]
@ -120,8 +122,8 @@ class DataParser(private val defaultDispatcher: CoroutineDispatcher) {
val argper: Double = tle[2].substring(34, 42).toDouble()
val meanan: Double = tle[2].substring(43, 51).toDouble()
val catnum: Int = tle[1].substring(2, 7).trim().toInt()
val bstar: Double = 1.0e-5 * tle[1].substring(53, 59).toDouble() /
10.0.pow(tle[1].substring(60, 61).toDouble())
val bstar: Double =
1.0e-5 * tle[1].substring(53, 59).toDouble() / 10.0.pow(tle[1].substring(60, 61).toDouble())
return OrbitalData(name, epoch, meanmo, eccn, incl, raan, argper, meanan, catnum, bstar)
} catch (exception: Exception) {
return null
@ -153,8 +155,10 @@ class DataParser(private val defaultDispatcher: CoroutineDispatcher) {
val daysArray = arrayOf(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
var dayOfYear = dayOfMonth
// If leap year increment Feb days
if (((year / 4 == 0) && (year / 100 != 0)) || (year / 400 == 0)) daysArray[1]++
for (i in 0 until month - 1) { dayOfYear += daysArray[i] }
if (isLeapYear(year)) daysArray[1]++
for (i in 0 until month - 1) {
dayOfYear += daysArray[i]
}
return dayOfYear
}
}

Wyświetl plik

@ -17,13 +17,13 @@
*/
package com.rtbishop.look4sat.utility
import java.net.InetSocketAddress
import java.nio.ByteBuffer
import java.nio.channels.SocketChannel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.launch
import java.net.InetSocketAddress
import java.nio.ByteBuffer
import java.nio.channels.SocketChannel
class DataReporter(private val reporterScope: CoroutineScope) {
@ -56,7 +56,7 @@ class DataReporter(private val reporterScope: CoroutineScope) {
if (rotationSocketChannel == null) {
rotationSocketChannel = SocketChannel.open(InetSocketAddress(server, port))
} else {
val buffer = ByteBuffer.wrap("\\set_pos $azimuth $elevation\n".toByteArray())
val buffer = ByteBuffer.wrap("\\P $azimuth $elevation\n".toByteArray())
rotationSocketChannel?.write(buffer)
}
}.onFailure { error ->

Wyświetl plik

@ -31,6 +31,7 @@ class DataParserTest {
private val validCSVStream = """
OBJECT_NAME,OBJECT_ID,EPOCH,MEAN_MOTION,ECCENTRICITY,INCLINATION,RA_OF_ASC_NODE,ARG_OF_PERICENTER,MEAN_ANOMALY,EPHEMERIS_TYPE,CLASSIFICATION_TYPE,NORAD_CAT_ID,ELEMENT_SET_NO,REV_AT_EPOCH,BSTAR,MEAN_MOTION_DOT,MEAN_MOTION_DDOT
ISS (ZARYA),1998-067A,2021-11-16T12:28:09.322176,15.48582035,.0004694,51.6447,309.4881,203.6966,299.8876,0,U,25544,999,31220,.31985E-4,.1288E-4,0
ISS (ZARYA),1998-067A,2024-03-09T05:45:04.737024,15.49756209,.0005741,51.6418,90.7424,343.9724,92.8274,0,U,25544,999,44305,.25016E-3,.1373E-3,0
FLTSATCOM 8 (USA 46),1989-077A,2022-01-07T11:37:38.074080,1.00273350,.0001114,12.9044,1.3272,91.5769,260.4200,0,U,20253,999,24434,0,-.85E-6,0
""".trimIndent().byteInputStream()
private val invalidCSVStream = """
@ -41,6 +42,9 @@ class DataParserTest {
ISS (ZARYA)
1 25544U 98067A 21320.51955234 .00001288 00000+0 31985-4 0 9990
2 25544 51.6447 309.4881 0004694 203.6966 299.8876 15.48582035312205
ISS (ZARYA)
1 25544U 98067A 24069.23963816 .00013730 00000+0 25016-3 0 9999
2 25544 51.6418 90.7424 0005741 343.9724 92.8274 15.49756209443058
FLTSATCOM 8 (USA 46)
1 20253U 89077A 22007.48446845 -.00000085 00000+0 00000+0 0 9999
2 20253 12.9044 1.3272 0001114 91.5769 260.4200 1.00273350244345
@ -60,6 +64,7 @@ class DataParserTest {
fun `Given valid CSV stream returns valid data`() = runTest(testDispatcher) {
val parsedList = dataParser.parseCSVStream(validCSVStream)
assert(parsedList[0].epoch == 21320.51955234)
assert(parsedList[1].epoch == 24069.23963816)
}
@Test
@ -72,6 +77,7 @@ class DataParserTest {
fun `Given valid TLE stream returns valid data`() = runTest(testDispatcher) {
val parsedList = dataParser.parseTLEStream(validTLEStream)
assert(parsedList[0].epoch == 21320.51955234)
assert(parsedList[1].epoch == 24069.23963816)
}
@Test
@ -98,4 +104,12 @@ class DataParserTest {
val parsedList = dataParser.parseJSONStream(invalidJSONStream)
assert(parsedList.isEmpty())
}
@Test
fun `Function isLeapYear returns correct data`() = runTest(testDispatcher) {
val years = listOf(1900, 1984, 1994, 2016, 2022, 2024, 2042, 2048)
val answers = listOf(false, true, false, true, false, true, false, true)
val results = years.map { dataParser.isLeapYear(it) }
assert(results == answers)
}
}

Wyświetl plik

@ -1,11 +1,11 @@
buildscript {
ext {
hilt_version = '2.44.2'
application_version = '7.4.0'
application_version = '8.3.0'
library_version = '7.1.2'
kotlin_android_version = '1.8.0'
core_ktx_version = '1.9.0'
core_splashscreen_version = '1.0.0'
core_splashscreen_version = '1.0.1'
constraint_version = '2.1.4'
lifecycle_version = '2.5.1'
navigation_version = '2.5.3'

Wyświetl plik

@ -0,0 +1,4 @@
Aligned ROTCTL command with Gpredict #121
Added ingoring inactive transmitters #125
Fixed the satellite predictions bug #126
Added date to a satellite pass ENG #127

Wyświetl plik

@ -1 +1,4 @@
Fixed the satellite data update bug #108
Aligned ROTCTL command with Gpredict #121
Added ingoring inactive transmitters #125
Fixed the satellite predictions bug #126
Added date to a satellite pass ENG #127

Wyświetl plik

@ -21,3 +21,5 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false

Wyświetl plik

@ -1,6 +1,6 @@
#Fri Jan 27 13:22:02 GMT 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME