Code refactoring, moving classes to new packages

This commit is contained in:
Arty Bishop committed 2021-02-28 19:00:08 +00:00
1 parent 4fa2f13834
commit 4c83cd2e21
38 files changed
+285 -289

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"> android:label="@string/app_name">
<activity <activity
android:name=".ui.mainScreen.MainActivity" android:name=".ui.MainActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/AppTheme.Splash"> android:theme="@style/AppTheme.Splash">
<intent-filter> <intent-filter>
@@ -1,20 +1,20 @@
/******************************************************************************* /*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.data package com.rtbishop.look4sat.data
@@ -1,20 +1,20 @@
/******************************************************************************* /*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.data package com.rtbishop.look4sat.data
@@ -24,8 +24,9 @@ import androidx.room.PrimaryKey
import com.github.amsacode.predict4java.TLE import com.github.amsacode.predict4java.TLE
@Entity(tableName = "entries") @Entity(tableName = "entries")
data class SatEntry(val tle: TLE, var isSelected: Boolean = false) { data class SatEntry(
@PrimaryKey val tle: TLE,
var catNum: Int = tle.catnum var isSelected: Boolean = false,
var name: String = tle.name @PrimaryKey val catNum: Int = tle.catnum,
} val name: String = tle.name
)
@@ -1,20 +1,20 @@
/******************************************************************************* /*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.data package com.rtbishop.look4sat.data
@@ -1,20 +1,20 @@
/******************************************************************************* /*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.data package com.rtbishop.look4sat.data
@@ -33,15 +33,15 @@ object DispatchersModule {
@Provides @Provides
@DefaultDispatcher @DefaultDispatcher
fun provideDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default fun getDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
@Provides @Provides
@IoDispatcher @IoDispatcher
fun provideIoDispatcher(): CoroutineDispatcher = Dispatchers.IO fun getIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
@Provides @Provides
@MainDispatcher @MainDispatcher
fun provideMainDispatcher(): CoroutineDispatcher = Dispatchers.Main fun getMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
} }
@Qualifier @Qualifier
@@ -19,7 +19,7 @@
package com.rtbishop.look4sat.di package com.rtbishop.look4sat.di
import com.rtbishop.look4sat.repo.remote.TransmittersApi import com.rtbishop.look4sat.repository.remoteData.TransmittersApi
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
@@ -42,7 +42,7 @@ object NetworkModule {
@Provides @Provides
@Singleton @Singleton
fun provideMoshi(): Moshi { fun getMoshi(): Moshi {
return Moshi.Builder().build() return Moshi.Builder().build()
} }
@@ -22,11 +22,11 @@ package com.rtbishop.look4sat.di
import android.content.ContentResolver import android.content.ContentResolver
import android.content.Context import android.content.Context
import androidx.room.Room import androidx.room.Room
import com.rtbishop.look4sat.repo.local.EntriesDao import com.rtbishop.look4sat.repository.localData.EntriesDao
import com.rtbishop.look4sat.repo.local.SatelliteDb import com.rtbishop.look4sat.repository.localData.SatelliteDb
import com.rtbishop.look4sat.repo.local.SourcesDao import com.rtbishop.look4sat.repository.localData.SourcesDao
import com.rtbishop.look4sat.repo.local.TransmittersDao import com.rtbishop.look4sat.repository.localData.TransmittersDao
import com.rtbishop.look4sat.utility.TypeConverters import com.rtbishop.look4sat.utility.RoomConverters
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
@@ -66,7 +66,7 @@ object RepositoryModule {
@Provides @Provides
@Singleton @Singleton
fun getSatelliteDb(@ApplicationContext context: Context, moshi: Moshi): SatelliteDb { fun getSatelliteDb(@ApplicationContext context: Context, moshi: Moshi): SatelliteDb {
TypeConverters.initialize(moshi) RoomConverters.initialize(moshi)
return Room.databaseBuilder(context, SatelliteDb::class.java, "satDb").build() return Room.databaseBuilder(context, SatelliteDb::class.java, "satDb").build()
} }
} }
@@ -1,42 +0,0 @@
/*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/
package com.rtbishop.look4sat.repo.local
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.rtbishop.look4sat.data.SatEntry
import com.rtbishop.look4sat.data.SatTrans
import com.rtbishop.look4sat.data.TleSource
@Database(
entities = [TleSource::class, SatEntry::class, SatTrans::class],
version = 1,
exportSchema = false
)
@TypeConverters(com.rtbishop.look4sat.utility.TypeConverters::class)
abstract class SatelliteDb : RoomDatabase() {
abstract fun sourcesDao(): SourcesDao
abstract fun entriesDao(): EntriesDao
abstract fun transmittersDao(): TransmittersDao
}
@@ -17,15 +17,16 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.repo package com.rtbishop.look4sat.repository
import android.content.ContentResolver import android.content.ContentResolver
import android.net.Uri import android.net.Uri
import com.github.amsacode.predict4java.TLE import com.github.amsacode.predict4java.TLE
import com.rtbishop.look4sat.data.SatEntry import com.rtbishop.look4sat.data.SatEntry
import com.rtbishop.look4sat.data.TleSource import com.rtbishop.look4sat.data.TleSource
import com.rtbishop.look4sat.repo.local.EntriesDao import com.rtbishop.look4sat.di.IoDispatcher
import kotlinx.coroutines.Dispatchers import com.rtbishop.look4sat.repository.localData.EntriesDao
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
@@ -34,30 +35,37 @@ import java.io.InputStream
import javax.inject.Inject import javax.inject.Inject
class EntriesRepo @Inject constructor( class EntriesRepo @Inject constructor(
private val resolver: ContentResolver, private val entriesDao: EntriesDao,
private val client: OkHttpClient, private val client: OkHttpClient,
private val entriesDao: EntriesDao private val resolver: ContentResolver,
@IoDispatcher private val ioDispatcher: CoroutineDispatcher
) { ) {
fun getEntries(): Flow<List<SatEntry>> { fun getEntries(): Flow<List<SatEntry>> {
return entriesDao.getEntries() return entriesDao.getEntries()
} }
suspend fun updateEntriesFromFile(fileUri: Uri) { suspend fun getSelectedEntries(): List<SatEntry> {
withContext(Dispatchers.IO) { return entriesDao.getSelectedEntries()
kotlin.runCatching { }
resolver.openInputStream(fileUri)?.use { stream ->
val importedEntries = TLE.importSat(stream).map { SatEntry(it) } suspend fun updateEntriesSelection(catNums: List<Int>) {
val selection = entriesDao.getEntriesSelection() entriesDao.updateEntriesSelection(catNums)
entriesDao.insertEntries(importedEntries) }
entriesDao.updateEntriesSelection(selection)
suspend fun updateEntriesFromFile(uri: Uri) {
withContext(ioDispatcher) {
runCatching {
resolver.openInputStream(uri)?.use { stream ->
val importedEntries = TLE.importSat(stream).map { tle -> SatEntry(tle) }
updateAndRestoreSelection(importedEntries)
} }
} }
} }
} }
suspend fun updateEntriesFromSources(sources: List<TleSource>) { suspend fun updateEntriesFromWeb(sources: List<TleSource>) {
withContext(Dispatchers.IO) { withContext(ioDispatcher) {
val streams = mutableListOf<InputStream>() val streams = mutableListOf<InputStream>()
sources.forEach { source -> sources.forEach { source ->
val request = Request.Builder().url(source.url).build() val request = Request.Builder().url(source.url).build()
@@ -69,13 +77,13 @@ class EntriesRepo @Inject constructor(
val entries = TLE.importSat(stream).map { tle -> SatEntry(tle) } val entries = TLE.importSat(stream).map { tle -> SatEntry(tle) }
importedEntries.addAll(entries) importedEntries.addAll(entries)
} }
val selection = entriesDao.getEntriesSelection() updateAndRestoreSelection(importedEntries)
entriesDao.insertEntries(importedEntries)
entriesDao.updateEntriesSelection(selection)
} }
} }
suspend fun updateEntriesSelection(satIds: List<Int>) { private suspend fun updateAndRestoreSelection(entries: List<SatEntry>) {
entriesDao.updateEntriesSelection(satIds) val selectedCatNums = entriesDao.getSelectedCatNums()
entriesDao.insertEntries(entries)
entriesDao.updateEntriesSelection(selectedCatNums)
} }
} }
@@ -17,10 +17,10 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.repo package com.rtbishop.look4sat.repository
import com.rtbishop.look4sat.data.TleSource import com.rtbishop.look4sat.data.TleSource
import com.rtbishop.look4sat.repo.local.SourcesDao import com.rtbishop.look4sat.repository.localData.SourcesDao
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import javax.inject.Inject import javax.inject.Inject
@@ -17,24 +17,24 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.repo package com.rtbishop.look4sat.repository
import com.rtbishop.look4sat.data.SatTrans import com.rtbishop.look4sat.data.SatTrans
import com.rtbishop.look4sat.repo.local.TransmittersDao import com.rtbishop.look4sat.repository.localData.TransmittersDao
import com.rtbishop.look4sat.repo.remote.TransmittersApi import com.rtbishop.look4sat.repository.remoteData.TransmittersApi
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import javax.inject.Inject import javax.inject.Inject
class TransmittersRepo @Inject constructor( class TransmittersRepo @Inject constructor(
private val transmittersDao: TransmittersDao, private val transmittersApi: TransmittersApi,
private val transmittersApi: TransmittersApi private val transmittersDao: TransmittersDao
) { ) {
fun getTransmittersForSat(satId: Int): Flow<List<SatTrans>> { fun getTransmittersForSat(catNum: Int): Flow<List<SatTrans>> {
return transmittersDao.getTransmittersForSat(satId) return transmittersDao.getTransmittersForSat(catNum)
} }
suspend fun updateTransmitters() { suspend fun updateTransmitters() {
transmittersDao.updateTransmitters(transmittersApi.getTransmitters()) transmittersDao.insertTransmitters(transmittersApi.fetchTransmitters())
} }
} }
@@ -17,7 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.repo.local package com.rtbishop.look4sat.repository.localData
import androidx.room.* import androidx.room.*
import com.rtbishop.look4sat.data.SatEntry import com.rtbishop.look4sat.data.SatEntry
@@ -28,22 +28,25 @@ interface EntriesDao {
@Query("SELECT * FROM entries ORDER BY name ASC") @Query("SELECT * FROM entries ORDER BY name ASC")
fun getEntries(): Flow<List<SatEntry>> fun getEntries(): Flow<List<SatEntry>>
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertEntries(entries: List<SatEntry>) suspend fun insertEntries(entries: List<SatEntry>)
@Query("SELECT * FROM entries WHERE isSelected = 1")
suspend fun getSelectedEntries(): List<SatEntry>
@Query("SELECT catNum FROM entries WHERE isSelected = 1") @Query("SELECT catNum FROM entries WHERE isSelected = 1")
suspend fun getEntriesSelection(): List<Int> suspend fun getSelectedCatNums(): List<Int>
@Transaction @Transaction
suspend fun updateEntriesSelection(satIds: List<Int>) { suspend fun updateEntriesSelection(catNums: List<Int>) {
clearSelection() clearSelection()
satIds.forEach { updateSelection(it) } catNums.forEach { catNum -> updateSelection(catNum) }
} }
@Query("UPDATE entries SET isSelected = 0") @Query("UPDATE entries SET isSelected = 0")
suspend fun clearSelection() suspend fun clearSelection()
@Query("UPDATE entries SET isSelected = 1 WHERE catNum = :satId") @Query("UPDATE entries SET isSelected = 1 WHERE catNum = :catNum")
suspend fun updateSelection(satId: Int) suspend fun updateSelection(catNum: Int)
} }
@@ -0,0 +1,39 @@
/*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/
package com.rtbishop.look4sat.repository.localData
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.rtbishop.look4sat.data.SatEntry
import com.rtbishop.look4sat.data.SatTrans
import com.rtbishop.look4sat.data.TleSource
import com.rtbishop.look4sat.utility.RoomConverters
@Database(entities = [TleSource::class, SatEntry::class, SatTrans::class], version = 1)
@TypeConverters(RoomConverters::class)
abstract class SatelliteDb : RoomDatabase() {
abstract fun sourcesDao(): SourcesDao
abstract fun entriesDao(): EntriesDao
abstract fun transmittersDao(): TransmittersDao
}
@@ -17,7 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.repo.local package com.rtbishop.look4sat.repository.localData
import androidx.room.* import androidx.room.*
import com.rtbishop.look4sat.data.TleSource import com.rtbishop.look4sat.data.TleSource
@@ -17,27 +17,21 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.repo.local package com.rtbishop.look4sat.repository.localData
import androidx.room.* import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.rtbishop.look4sat.data.SatTrans import com.rtbishop.look4sat.data.SatTrans
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
@Dao @Dao
interface TransmittersDao { interface TransmittersDao {
@Query("SELECT * FROM transmitters WHERE isAlive = 1 and catNum = :satId") @Query("SELECT * FROM transmitters WHERE isAlive = 1 and catNum = :catNum")
fun getTransmittersForSat(satId: Int): Flow<List<SatTrans>> fun getTransmittersForSat(catNum: Int): Flow<List<SatTrans>>
@Transaction
suspend fun updateTransmitters(transmitters: List<SatTrans>) {
clearTransmitters()
insertTransmitters(transmitters)
}
@Query("DELETE FROM transmitters")
suspend fun clearTransmitters()
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertTransmitters(transmitters: List<SatTrans>) suspend fun insertTransmitters(transmitters: List<SatTrans>)
} }
@@ -17,7 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.repo.remote package com.rtbishop.look4sat.repository.remoteData
import com.rtbishop.look4sat.data.SatTrans import com.rtbishop.look4sat.data.SatTrans
import retrofit2.http.GET import retrofit2.http.GET
@@ -25,5 +25,5 @@ import retrofit2.http.GET
interface TransmittersApi { interface TransmittersApi {
@GET("transmitters/") @GET("transmitters/")
suspend fun getTransmitters(): List<SatTrans> suspend fun fetchTransmitters(): List<SatTrans>
} }
@@ -17,7 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@@ -17,15 +17,15 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat package com.rtbishop.look4sat.ui
import android.net.Uri import android.net.Uri
import androidx.lifecycle.* import androidx.lifecycle.*
import com.github.amsacode.predict4java.SatelliteFactory import com.github.amsacode.predict4java.SatelliteFactory
import com.rtbishop.look4sat.data.* import com.rtbishop.look4sat.data.*
import com.rtbishop.look4sat.repo.EntriesRepo import com.rtbishop.look4sat.repository.EntriesRepo
import com.rtbishop.look4sat.repo.SourcesRepo import com.rtbishop.look4sat.repository.SourcesRepo
import com.rtbishop.look4sat.repo.TransmittersRepo import com.rtbishop.look4sat.repository.TransmittersRepo
import com.rtbishop.look4sat.utility.PrefsManager import com.rtbishop.look4sat.utility.PrefsManager
import com.rtbishop.look4sat.utility.getPredictor import com.rtbishop.look4sat.utility.getPredictor
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
@@ -107,7 +107,7 @@ class SharedViewModel @Inject constructor(
viewModelScope.launch { viewModelScope.launch {
try { try {
sourcesRepo.updateSources(sources) sourcesRepo.updateSources(sources)
entriesRepo.updateEntriesFromSources(sources) entriesRepo.updateEntriesFromWeb(sources)
transmittersRepo.updateTransmitters() transmittersRepo.updateTransmitters()
} catch (exception: Exception) { } catch (exception: Exception) {
postAppEvent(Event(1)) postAppEvent(Event(1))
@@ -1,23 +1,23 @@
/******************************************************************************* /*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.adapters package com.rtbishop.look4sat.ui.entriesScreen
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
@@ -2,22 +2,22 @@
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.entriesScreen
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
@@ -29,10 +29,9 @@ import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.rtbishop.look4sat.R import com.rtbishop.look4sat.R
import com.rtbishop.look4sat.SharedViewModel
import com.rtbishop.look4sat.data.SatEntry import com.rtbishop.look4sat.data.SatEntry
import com.rtbishop.look4sat.databinding.FragmentEntriesBinding import com.rtbishop.look4sat.databinding.FragmentEntriesBinding
import com.rtbishop.look4sat.ui.adapters.EntriesAdapter import com.rtbishop.look4sat.ui.SharedViewModel
import com.rtbishop.look4sat.utility.RecyclerDivider import com.rtbishop.look4sat.utility.RecyclerDivider
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
@@ -17,7 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.infoScreen
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
@@ -2,22 +2,22 @@
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.mapScreen
import android.graphics.Color import android.graphics.Color
import android.graphics.ColorMatrix import android.graphics.ColorMatrix
@@ -30,11 +30,11 @@ import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import com.github.amsacode.predict4java.Position import com.github.amsacode.predict4java.Position
import com.rtbishop.look4sat.R import com.rtbishop.look4sat.R
import com.rtbishop.look4sat.SharedViewModel
import com.rtbishop.look4sat.data.Result import com.rtbishop.look4sat.data.Result
import com.rtbishop.look4sat.data.SatPass import com.rtbishop.look4sat.data.SatPass
import com.rtbishop.look4sat.data.SelectedSat import com.rtbishop.look4sat.data.SelectedSat
import com.rtbishop.look4sat.databinding.FragmentMapBinding import com.rtbishop.look4sat.databinding.FragmentMapBinding
import com.rtbishop.look4sat.ui.SharedViewModel
import com.rtbishop.look4sat.utility.PrefsManager import com.rtbishop.look4sat.utility.PrefsManager
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import org.osmdroid.config.Configuration import org.osmdroid.config.Configuration
@@ -17,7 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.mapScreen
import android.graphics.Color import android.graphics.Color
import android.graphics.Paint import android.graphics.Paint
@@ -2,22 +2,22 @@
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.adapters package com.rtbishop.look4sat.ui.passesScreen
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
@@ -2,22 +2,22 @@
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.passesScreen
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
@@ -26,11 +26,10 @@ import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.SimpleItemAnimator import androidx.recyclerview.widget.SimpleItemAnimator
import com.rtbishop.look4sat.R import com.rtbishop.look4sat.R
import com.rtbishop.look4sat.SharedViewModel
import com.rtbishop.look4sat.data.Result import com.rtbishop.look4sat.data.Result
import com.rtbishop.look4sat.data.SatPass import com.rtbishop.look4sat.data.SatPass
import com.rtbishop.look4sat.databinding.FragmentPassesBinding import com.rtbishop.look4sat.databinding.FragmentPassesBinding
import com.rtbishop.look4sat.ui.adapters.PassesAdapter import com.rtbishop.look4sat.ui.SharedViewModel
import com.rtbishop.look4sat.utility.PrefsManager import com.rtbishop.look4sat.utility.PrefsManager
import com.rtbishop.look4sat.utility.RecyclerDivider import com.rtbishop.look4sat.utility.RecyclerDivider
import com.rtbishop.look4sat.utility.formatForTimer import com.rtbishop.look4sat.utility.formatForTimer
@@ -1,23 +1,23 @@
/******************************************************************************* /*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.polarScreen
import android.content.Context import android.content.Context
import android.hardware.Sensor import android.hardware.Sensor
@@ -32,12 +32,10 @@ import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.SimpleItemAnimator import androidx.recyclerview.widget.SimpleItemAnimator
import com.rtbishop.look4sat.R import com.rtbishop.look4sat.R
import com.rtbishop.look4sat.SharedViewModel
import com.rtbishop.look4sat.data.Result import com.rtbishop.look4sat.data.Result
import com.rtbishop.look4sat.data.SatPass import com.rtbishop.look4sat.data.SatPass
import com.rtbishop.look4sat.databinding.FragmentPolarBinding import com.rtbishop.look4sat.databinding.FragmentPolarBinding
import com.rtbishop.look4sat.ui.adapters.TransAdapter import com.rtbishop.look4sat.ui.SharedViewModel
import com.rtbishop.look4sat.ui.views.PolarView
import com.rtbishop.look4sat.utility.PrefsManager import com.rtbishop.look4sat.utility.PrefsManager
import com.rtbishop.look4sat.utility.RecyclerDivider import com.rtbishop.look4sat.utility.RecyclerDivider
import com.rtbishop.look4sat.utility.formatForTimer import com.rtbishop.look4sat.utility.formatForTimer
@@ -104,7 +102,7 @@ class PolarFragment : Fragment(R.layout.fragment_polar), SensorEventListener {
viewModel.getPasses().observe(viewLifecycleOwner, { result -> viewModel.getPasses().observe(viewLifecycleOwner, { result ->
if (result is Result.Success) { if (result is Result.Success) {
satPass = result.data[requireArguments().getInt("index")] satPass = result.data[requireArguments().getInt("index")]
polarView = PolarView(requireContext(), satPass) polarView = PolarView(requireContext()).apply { setPass(satPass) }
binding.frame.addView(polarView) binding.frame.addView(polarView)
observeTransmitters() observeTransmitters()
} }
@@ -17,7 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.views package com.rtbishop.look4sat.ui.polarScreen
import android.content.Context import android.content.Context
import android.graphics.Canvas import android.graphics.Canvas
@@ -33,12 +33,8 @@ import kotlin.math.cos
import kotlin.math.sin import kotlin.math.sin
class PolarView(context: Context) : View(context) { class PolarView(context: Context) : View(context) {
constructor(context: Context, satPass: SatPass) : this(context) { private lateinit var satPass: SatPass
pass = satPass
}
private lateinit var pass: SatPass
private val polarWidth = resources.displayMetrics.widthPixels private val polarWidth = resources.displayMetrics.widthPixels
private val polarCenter = polarWidth / 2f private val polarCenter = polarWidth / 2f
private val scale = resources.displayMetrics.density private val scale = resources.displayMetrics.density
@@ -69,15 +65,19 @@ class PolarView(context: Context) : View(context) {
color = ContextCompat.getColor(context, R.color.themeLight) color = ContextCompat.getColor(context, R.color.themeLight)
style = Paint.Style.FILL style = Paint.Style.FILL
} }
fun setPass(satPass: SatPass) {
this.satPass = satPass
}
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
canvas.translate(polarCenter, polarCenter) canvas.translate(polarCenter, polarCenter)
drawRadarView(canvas) drawRadarView(canvas)
drawRadarText(canvas) drawRadarText(canvas)
if (!pass.tle.isDeepspace) drawPassTrajectory(canvas, pass) if (!satPass.tle.isDeepspace) drawPassTrajectory(canvas, satPass)
drawSatellite(canvas, pass) drawSatellite(canvas, satPass)
} }
private fun drawRadarView(cvs: Canvas) { private fun drawRadarView(cvs: Canvas) {
cvs.drawLine(-radius, 0f, radius, 0f, radarPaint) cvs.drawLine(-radius, 0f, radius, 0f, radarPaint)
cvs.drawLine(0f, -radius, 0f, radius, radarPaint) cvs.drawLine(0f, -radius, 0f, radius, radarPaint)
@@ -2,22 +2,22 @@
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.adapters package com.rtbishop.look4sat.ui.polarScreen
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
@@ -17,7 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.prefsScreen
import android.Manifest import android.Manifest
import android.content.pm.PackageManager import android.content.pm.PackageManager
@@ -2,22 +2,22 @@
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.adapters package com.rtbishop.look4sat.ui.sourcesDialog
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
@@ -1,23 +1,23 @@
/******************************************************************************* /*******************************************************************************
Look4Sat. Amateur radio satellite tracker and pass predictor. Look4Sat. Amateur radio satellite tracker and pass predictor.
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.sourcesDialog
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@@ -28,10 +28,9 @@ import androidx.appcompat.app.AppCompatDialogFragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.rtbishop.look4sat.R import com.rtbishop.look4sat.R
import com.rtbishop.look4sat.SharedViewModel import com.rtbishop.look4sat.ui.SharedViewModel
import com.rtbishop.look4sat.data.TleSource import com.rtbishop.look4sat.data.TleSource
import com.rtbishop.look4sat.databinding.DialogSourcesBinding import com.rtbishop.look4sat.databinding.DialogSourcesBinding
import com.rtbishop.look4sat.ui.adapters.SourcesAdapter
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint @AndroidEntryPoint
@@ -17,7 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
******************************************************************************/ ******************************************************************************/
package com.rtbishop.look4sat.ui.mainScreen package com.rtbishop.look4sat.ui.splashDialog
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@@ -26,6 +26,7 @@ import com.github.amsacode.predict4java.GroundStationPosition
import javax.inject.Inject import javax.inject.Inject
class PrefsManager @Inject constructor(val preferences: SharedPreferences) { class PrefsManager @Inject constructor(val preferences: SharedPreferences) {
companion object { companion object {
const val keyLatitude = "latitude" const val keyLatitude = "latitude"
const val keyLongitude = "longitude" const val keyLongitude = "longitude"
@@ -61,7 +62,6 @@ class PrefsManager @Inject constructor(val preferences: SharedPreferences) {
putString(keyLatitude, latitude.toString()) putString(keyLatitude, latitude.toString())
putString(keyLongitude, longitude.toString()) putString(keyLongitude, longitude.toString())
putString(keyAltitude, altitude.toString()) putString(keyAltitude, altitude.toString())
apply()
} }
} }
@@ -90,9 +90,6 @@ class PrefsManager @Inject constructor(val preferences: SharedPreferences) {
} }
fun setFirstLaunchDone() { fun setFirstLaunchDone() {
preferences.edit { preferences.edit { putBoolean(keyIsFirstLaunch, false) }
putBoolean(keyIsFirstLaunch, false)
apply()
}
} }
} }
@@ -26,18 +26,19 @@ import androidx.recyclerview.widget.RecyclerView
class RecyclerDivider(private val resId: Int) : RecyclerView.ItemDecoration() { class RecyclerDivider(private val resId: Int) : RecyclerView.ItemDecoration() {
override fun onDrawOver(c: Canvas, parent: RecyclerView) { override fun onDrawOver(c: Canvas, parent: RecyclerView) {
val divider = ContextCompat.getDrawable(parent.context, resId)!! ContextCompat.getDrawable(parent.context, resId)?.let { drawable ->
val left = parent.paddingLeft val leftPos = parent.paddingLeft
val right = parent.width - parent.paddingRight val rightPos = parent.width - parent.paddingRight
parent.adapter?.itemCount?.let { childCount -> parent.adapter?.itemCount?.let { childCount ->
for (i in 0 until childCount) { for (i in 0 until childCount) {
if (i == (childCount - 1)) continue if (i == (childCount - 1)) continue
parent.getChildAt(i)?.let { parent.getChildAt(i)?.let { view ->
val params = it.layoutParams as RecyclerView.LayoutParams val params = view.layoutParams as RecyclerView.LayoutParams
val top = it.bottom + params.bottomMargin val topPos = view.bottom + params.bottomMargin
val bottom = top + divider.intrinsicHeight val bottomPos = topPos + drawable.intrinsicHeight
divider.setBounds(left, top, right, bottom) drawable.setBounds(leftPos, topPos, rightPos, bottomPos)
divider.draw(c) drawable.draw(c)
}
} }
} }
} }
@@ -24,7 +24,7 @@ import com.github.amsacode.predict4java.TLE
import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
object TypeConverters { object RoomConverters {
private lateinit var tleAdapter: JsonAdapter<TLE> private lateinit var tleAdapter: JsonAdapter<TLE>
+1 -1
View File
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.mainScreen.InfoFragment"> tools:context=".ui.infoScreen.InfoFragment">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
+8 -8
View File
@@ -7,7 +7,7 @@
<fragment <fragment
android:id="@+id/nav_entries" android:id="@+id/nav_entries"
android:name="com.rtbishop.look4sat.ui.mainScreen.EntriesFragment" android:name="com.rtbishop.look4sat.ui.entriesScreen.EntriesFragment"
tools:layout="@layout/fragment_entries"> tools:layout="@layout/fragment_entries">
<action <action
android:id="@+id/action_entries_to_passes" android:id="@+id/action_entries_to_passes"
@@ -27,7 +27,7 @@
<fragment <fragment
android:id="@+id/nav_passes" android:id="@+id/nav_passes"
android:name="com.rtbishop.look4sat.ui.mainScreen.PassesFragment" android:name="com.rtbishop.look4sat.ui.passesScreen.PassesFragment"
tools:layout="@layout/fragment_passes"> tools:layout="@layout/fragment_passes">
<action <action
android:id="@+id/action_passes_to_polar" android:id="@+id/action_passes_to_polar"
@@ -40,7 +40,7 @@
<fragment <fragment
android:id="@+id/nav_polar" android:id="@+id/nav_polar"
android:name="com.rtbishop.look4sat.ui.mainScreen.PolarFragment" android:name="com.rtbishop.look4sat.ui.polarScreen.PolarFragment"
tools:layout="@layout/fragment_polar"> tools:layout="@layout/fragment_polar">
<action <action
android:id="@+id/action_polar_to_passes" android:id="@+id/action_polar_to_passes"
@@ -55,24 +55,24 @@
<fragment <fragment
android:id="@+id/nav_map" android:id="@+id/nav_map"
android:name="com.rtbishop.look4sat.ui.mainScreen.MapFragment" android:name="com.rtbishop.look4sat.ui.mapScreen.MapFragment"
tools:layout="@layout/fragment_map" /> tools:layout="@layout/fragment_map" />
<fragment <fragment
android:id="@+id/nav_prefs" android:id="@+id/nav_prefs"
android:name="com.rtbishop.look4sat.ui.mainScreen.PrefsFragment" /> android:name="com.rtbishop.look4sat.ui.prefsScreen.PrefsFragment" />
<fragment <fragment
android:id="@+id/nav_info" android:id="@+id/nav_info"
android:name="com.rtbishop.look4sat.ui.mainScreen.InfoFragment" android:name="com.rtbishop.look4sat.ui.infoScreen.InfoFragment"
tools:layout="@layout/fragment_info" /> tools:layout="@layout/fragment_info" />
<dialog <dialog
android:id="@+id/nav_dialog_sources" android:id="@+id/nav_dialog_sources"
android:name="com.rtbishop.look4sat.ui.mainScreen.SourcesDialog" android:name="com.rtbishop.look4sat.ui.sourcesDialog.SourcesDialog"
tools:layout="@layout/dialog_sources" /> tools:layout="@layout/dialog_sources" />
<dialog <dialog
android:id="@+id/nav_dialog_splash" android:id="@+id/nav_dialog_splash"
android:name="com.rtbishop.look4sat.ui.mainScreen.SplashDialog" android:name="com.rtbishop.look4sat.ui.splashDialog.SplashDialog"
tools:layout="@layout/dialog_splash" /> tools:layout="@layout/dialog_splash" />
</navigation> </navigation>