mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Code refactoring, moving classes to new packages
This commit is contained in:
1 parent
4fa2f13834
commit
4c83cd2e21
38 files changed
+285
-289
No files matched your search
@@ -11,7 +11,7 @@
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name">
|
||||
<activity
|
||||
android:name=".ui.mainScreen.MainActivity"
|
||||
android:name=".ui.MainActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.Splash">
|
||||
<intent-filter>
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*******************************************************************************
|
||||
Look4Sat. Amateur radio satellite tracker and pass predictor.
|
||||
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
||||
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 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.
|
||||
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.
|
||||
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.data
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*******************************************************************************
|
||||
Look4Sat. Amateur radio satellite tracker and pass predictor.
|
||||
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
||||
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 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.
|
||||
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.
|
||||
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.data
|
||||
@@ -24,8 +24,9 @@ import androidx.room.PrimaryKey
|
||||
import com.github.amsacode.predict4java.TLE
|
||||
|
||||
@Entity(tableName = "entries")
|
||||
data class SatEntry(val tle: TLE, var isSelected: Boolean = false) {
|
||||
@PrimaryKey
|
||||
var catNum: Int = tle.catnum
|
||||
var name: String = tle.name
|
||||
}
|
||||
data class SatEntry(
|
||||
val tle: TLE,
|
||||
var isSelected: Boolean = false,
|
||||
@PrimaryKey val catNum: Int = tle.catnum,
|
||||
val name: String = tle.name
|
||||
)
|
||||
@@ -1,20 +1,20 @@
|
||||
/*******************************************************************************
|
||||
Look4Sat. Amateur radio satellite tracker and pass predictor.
|
||||
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
||||
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 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.
|
||||
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.
|
||||
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.data
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*******************************************************************************
|
||||
Look4Sat. Amateur radio satellite tracker and pass predictor.
|
||||
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
||||
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 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.
|
||||
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.
|
||||
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.data
|
||||
|
||||
@@ -33,15 +33,15 @@ object DispatchersModule {
|
||||
|
||||
@Provides
|
||||
@DefaultDispatcher
|
||||
fun provideDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
|
||||
fun getDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
|
||||
|
||||
@Provides
|
||||
@IoDispatcher
|
||||
fun provideIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
|
||||
fun getIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
|
||||
|
||||
@Provides
|
||||
@MainDispatcher
|
||||
fun provideMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
|
||||
fun getMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
|
||||
}
|
||||
|
||||
@Qualifier
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
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 dagger.Module
|
||||
import dagger.Provides
|
||||
@@ -42,7 +42,7 @@ object NetworkModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideMoshi(): Moshi {
|
||||
fun getMoshi(): Moshi {
|
||||
return Moshi.Builder().build()
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ package com.rtbishop.look4sat.di
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import com.rtbishop.look4sat.repo.local.EntriesDao
|
||||
import com.rtbishop.look4sat.repo.local.SatelliteDb
|
||||
import com.rtbishop.look4sat.repo.local.SourcesDao
|
||||
import com.rtbishop.look4sat.repo.local.TransmittersDao
|
||||
import com.rtbishop.look4sat.utility.TypeConverters
|
||||
import com.rtbishop.look4sat.repository.localData.EntriesDao
|
||||
import com.rtbishop.look4sat.repository.localData.SatelliteDb
|
||||
import com.rtbishop.look4sat.repository.localData.SourcesDao
|
||||
import com.rtbishop.look4sat.repository.localData.TransmittersDao
|
||||
import com.rtbishop.look4sat.utility.RoomConverters
|
||||
import com.squareup.moshi.Moshi
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
@@ -66,7 +66,7 @@ object RepositoryModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun getSatelliteDb(@ApplicationContext context: Context, moshi: Moshi): SatelliteDb {
|
||||
TypeConverters.initialize(moshi)
|
||||
RoomConverters.initialize(moshi)
|
||||
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
|
||||
}
|
||||
+28
-20
@@ -17,15 +17,16 @@
|
||||
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.net.Uri
|
||||
import com.github.amsacode.predict4java.TLE
|
||||
import com.rtbishop.look4sat.data.SatEntry
|
||||
import com.rtbishop.look4sat.data.TleSource
|
||||
import com.rtbishop.look4sat.repo.local.EntriesDao
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import com.rtbishop.look4sat.di.IoDispatcher
|
||||
import com.rtbishop.look4sat.repository.localData.EntriesDao
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.OkHttpClient
|
||||
@@ -34,30 +35,37 @@ import java.io.InputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
class EntriesRepo @Inject constructor(
|
||||
private val resolver: ContentResolver,
|
||||
private val entriesDao: EntriesDao,
|
||||
private val client: OkHttpClient,
|
||||
private val entriesDao: EntriesDao
|
||||
private val resolver: ContentResolver,
|
||||
@IoDispatcher private val ioDispatcher: CoroutineDispatcher
|
||||
) {
|
||||
|
||||
fun getEntries(): Flow<List<SatEntry>> {
|
||||
return entriesDao.getEntries()
|
||||
}
|
||||
|
||||
suspend fun updateEntriesFromFile(fileUri: Uri) {
|
||||
withContext(Dispatchers.IO) {
|
||||
kotlin.runCatching {
|
||||
resolver.openInputStream(fileUri)?.use { stream ->
|
||||
val importedEntries = TLE.importSat(stream).map { SatEntry(it) }
|
||||
val selection = entriesDao.getEntriesSelection()
|
||||
entriesDao.insertEntries(importedEntries)
|
||||
entriesDao.updateEntriesSelection(selection)
|
||||
suspend fun getSelectedEntries(): List<SatEntry> {
|
||||
return entriesDao.getSelectedEntries()
|
||||
}
|
||||
|
||||
suspend fun updateEntriesSelection(catNums: List<Int>) {
|
||||
entriesDao.updateEntriesSelection(catNums)
|
||||
}
|
||||
|
||||
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>) {
|
||||
withContext(Dispatchers.IO) {
|
||||
suspend fun updateEntriesFromWeb(sources: List<TleSource>) {
|
||||
withContext(ioDispatcher) {
|
||||
val streams = mutableListOf<InputStream>()
|
||||
sources.forEach { source ->
|
||||
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) }
|
||||
importedEntries.addAll(entries)
|
||||
}
|
||||
val selection = entriesDao.getEntriesSelection()
|
||||
entriesDao.insertEntries(importedEntries)
|
||||
entriesDao.updateEntriesSelection(selection)
|
||||
updateAndRestoreSelection(importedEntries)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun updateEntriesSelection(satIds: List<Int>) {
|
||||
entriesDao.updateEntriesSelection(satIds)
|
||||
private suspend fun updateAndRestoreSelection(entries: List<SatEntry>) {
|
||||
val selectedCatNums = entriesDao.getSelectedCatNums()
|
||||
entriesDao.insertEntries(entries)
|
||||
entriesDao.updateEntriesSelection(selectedCatNums)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -17,10 +17,10 @@
|
||||
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.repo.local.SourcesDao
|
||||
import com.rtbishop.look4sat.repository.localData.SourcesDao
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import javax.inject.Inject
|
||||
|
||||
+8
-8
@@ -17,24 +17,24 @@
|
||||
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.repo.local.TransmittersDao
|
||||
import com.rtbishop.look4sat.repo.remote.TransmittersApi
|
||||
import com.rtbishop.look4sat.repository.localData.TransmittersDao
|
||||
import com.rtbishop.look4sat.repository.remoteData.TransmittersApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import javax.inject.Inject
|
||||
|
||||
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>> {
|
||||
return transmittersDao.getTransmittersForSat(satId)
|
||||
fun getTransmittersForSat(catNum: Int): Flow<List<SatTrans>> {
|
||||
return transmittersDao.getTransmittersForSat(catNum)
|
||||
}
|
||||
|
||||
suspend fun updateTransmitters() {
|
||||
transmittersDao.updateTransmitters(transmittersApi.getTransmitters())
|
||||
transmittersDao.insertTransmitters(transmittersApi.fetchTransmitters())
|
||||
}
|
||||
}
|
||||
+14
-11
@@ -17,7 +17,7 @@
|
||||
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 com.rtbishop.look4sat.data.SatEntry
|
||||
@@ -28,22 +28,25 @@ interface EntriesDao {
|
||||
|
||||
@Query("SELECT * FROM entries ORDER BY name ASC")
|
||||
fun getEntries(): Flow<List<SatEntry>>
|
||||
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
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")
|
||||
suspend fun getEntriesSelection(): List<Int>
|
||||
|
||||
suspend fun getSelectedCatNums(): List<Int>
|
||||
|
||||
@Transaction
|
||||
suspend fun updateEntriesSelection(satIds: List<Int>) {
|
||||
suspend fun updateEntriesSelection(catNums: List<Int>) {
|
||||
clearSelection()
|
||||
satIds.forEach { updateSelection(it) }
|
||||
catNums.forEach { catNum -> updateSelection(catNum) }
|
||||
}
|
||||
|
||||
|
||||
@Query("UPDATE entries SET isSelected = 0")
|
||||
suspend fun clearSelection()
|
||||
|
||||
@Query("UPDATE entries SET isSelected = 1 WHERE catNum = :satId")
|
||||
suspend fun updateSelection(satId: Int)
|
||||
|
||||
@Query("UPDATE entries SET isSelected = 1 WHERE catNum = :catNum")
|
||||
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
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
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 com.rtbishop.look4sat.data.TleSource
|
||||
+8
-14
@@ -17,27 +17,21 @@
|
||||
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 kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface TransmittersDao {
|
||||
|
||||
@Query("SELECT * FROM transmitters WHERE isAlive = 1 and catNum = :satId")
|
||||
fun getTransmittersForSat(satId: Int): Flow<List<SatTrans>>
|
||||
|
||||
@Transaction
|
||||
suspend fun updateTransmitters(transmitters: List<SatTrans>) {
|
||||
clearTransmitters()
|
||||
insertTransmitters(transmitters)
|
||||
}
|
||||
|
||||
@Query("DELETE FROM transmitters")
|
||||
suspend fun clearTransmitters()
|
||||
|
||||
@Query("SELECT * FROM transmitters WHERE isAlive = 1 and catNum = :catNum")
|
||||
fun getTransmittersForSat(catNum: Int): Flow<List<SatTrans>>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertTransmitters(transmitters: List<SatTrans>)
|
||||
}
|
||||
+2
-2
@@ -17,7 +17,7 @@
|
||||
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 retrofit2.http.GET
|
||||
@@ -25,5 +25,5 @@ import retrofit2.http.GET
|
||||
interface TransmittersApi {
|
||||
|
||||
@GET("transmitters/")
|
||||
suspend fun getTransmitters(): List<SatTrans>
|
||||
suspend fun fetchTransmitters(): List<SatTrans>
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
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 androidx.appcompat.app.AppCompatActivity
|
||||
+5
-5
@@ -17,15 +17,15 @@
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
******************************************************************************/
|
||||
|
||||
package com.rtbishop.look4sat
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.lifecycle.*
|
||||
import com.github.amsacode.predict4java.SatelliteFactory
|
||||
import com.rtbishop.look4sat.data.*
|
||||
import com.rtbishop.look4sat.repo.EntriesRepo
|
||||
import com.rtbishop.look4sat.repo.SourcesRepo
|
||||
import com.rtbishop.look4sat.repo.TransmittersRepo
|
||||
import com.rtbishop.look4sat.repository.EntriesRepo
|
||||
import com.rtbishop.look4sat.repository.SourcesRepo
|
||||
import com.rtbishop.look4sat.repository.TransmittersRepo
|
||||
import com.rtbishop.look4sat.utility.PrefsManager
|
||||
import com.rtbishop.look4sat.utility.getPredictor
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
@@ -107,7 +107,7 @@ class SharedViewModel @Inject constructor(
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
sourcesRepo.updateSources(sources)
|
||||
entriesRepo.updateEntriesFromSources(sources)
|
||||
entriesRepo.updateEntriesFromWeb(sources)
|
||||
transmittersRepo.updateTransmitters()
|
||||
} catch (exception: Exception) {
|
||||
postAppEvent(Event(1))
|
||||
+14
-14
@@ -1,23 +1,23 @@
|
||||
/*******************************************************************************
|
||||
Look4Sat. Amateur radio satellite tracker and pass predictor.
|
||||
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
||||
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 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.
|
||||
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.
|
||||
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.ui.adapters
|
||||
package com.rtbishop.look4sat.ui.entriesScreen
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
+5
-6
@@ -2,22 +2,22 @@
|
||||
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
|
||||
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,
|
||||
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
|
||||
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.ui.mainScreen
|
||||
package com.rtbishop.look4sat.ui.entriesScreen
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
@@ -29,10 +29,9 @@ import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.SharedViewModel
|
||||
import com.rtbishop.look4sat.data.SatEntry
|
||||
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 dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
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.net.Uri
|
||||
+5
-5
@@ -2,22 +2,22 @@
|
||||
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
|
||||
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,
|
||||
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
|
||||
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.ui.mainScreen
|
||||
package com.rtbishop.look4sat.ui.mapScreen
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.ColorMatrix
|
||||
@@ -30,11 +30,11 @@ import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.github.amsacode.predict4java.Position
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.SharedViewModel
|
||||
import com.rtbishop.look4sat.data.Result
|
||||
import com.rtbishop.look4sat.data.SatPass
|
||||
import com.rtbishop.look4sat.data.SelectedSat
|
||||
import com.rtbishop.look4sat.databinding.FragmentMapBinding
|
||||
import com.rtbishop.look4sat.ui.SharedViewModel
|
||||
import com.rtbishop.look4sat.utility.PrefsManager
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.osmdroid.config.Configuration
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
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.Paint
|
||||
+4
-4
@@ -2,22 +2,22 @@
|
||||
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
|
||||
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,
|
||||
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
|
||||
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.ui.adapters
|
||||
package com.rtbishop.look4sat.ui.passesScreen
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
+5
-6
@@ -2,22 +2,22 @@
|
||||
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
|
||||
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,
|
||||
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
|
||||
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.ui.mainScreen
|
||||
package com.rtbishop.look4sat.ui.passesScreen
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
@@ -26,11 +26,10 @@ import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.SharedViewModel
|
||||
import com.rtbishop.look4sat.data.Result
|
||||
import com.rtbishop.look4sat.data.SatPass
|
||||
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.RecyclerDivider
|
||||
import com.rtbishop.look4sat.utility.formatForTimer
|
||||
+16
-18
@@ -1,23 +1,23 @@
|
||||
/*******************************************************************************
|
||||
Look4Sat. Amateur radio satellite tracker and pass predictor.
|
||||
Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
||||
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 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.
|
||||
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.
|
||||
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.ui.mainScreen
|
||||
package com.rtbishop.look4sat.ui.polarScreen
|
||||
|
||||
import android.content.Context
|
||||
import android.hardware.Sensor
|
||||
@@ -32,12 +32,10 @@ import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.SharedViewModel
|
||||
import com.rtbishop.look4sat.data.Result
|
||||
import com.rtbishop.look4sat.data.SatPass
|
||||
import com.rtbishop.look4sat.databinding.FragmentPolarBinding
|
||||
import com.rtbishop.look4sat.ui.adapters.TransAdapter
|
||||
import com.rtbishop.look4sat.ui.views.PolarView
|
||||
import com.rtbishop.look4sat.ui.SharedViewModel
|
||||
import com.rtbishop.look4sat.utility.PrefsManager
|
||||
import com.rtbishop.look4sat.utility.RecyclerDivider
|
||||
import com.rtbishop.look4sat.utility.formatForTimer
|
||||
@@ -104,7 +102,7 @@ class PolarFragment : Fragment(R.layout.fragment_polar), SensorEventListener {
|
||||
viewModel.getPasses().observe(viewLifecycleOwner, { result ->
|
||||
if (result is Result.Success) {
|
||||
satPass = result.data[requireArguments().getInt("index")]
|
||||
polarView = PolarView(requireContext(), satPass)
|
||||
polarView = PolarView(requireContext()).apply { setPass(satPass) }
|
||||
binding.frame.addView(polarView)
|
||||
observeTransmitters()
|
||||
}
|
||||
+11
-11
@@ -17,7 +17,7 @@
|
||||
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.graphics.Canvas
|
||||
@@ -33,12 +33,8 @@ import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
class PolarView(context: Context) : View(context) {
|
||||
|
||||
constructor(context: Context, satPass: SatPass) : this(context) {
|
||||
pass = satPass
|
||||
}
|
||||
|
||||
private lateinit var pass: SatPass
|
||||
|
||||
private lateinit var satPass: SatPass
|
||||
private val polarWidth = resources.displayMetrics.widthPixels
|
||||
private val polarCenter = polarWidth / 2f
|
||||
private val scale = resources.displayMetrics.density
|
||||
@@ -69,15 +65,19 @@ class PolarView(context: Context) : View(context) {
|
||||
color = ContextCompat.getColor(context, R.color.themeLight)
|
||||
style = Paint.Style.FILL
|
||||
}
|
||||
|
||||
|
||||
fun setPass(satPass: SatPass) {
|
||||
this.satPass = satPass
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
canvas.translate(polarCenter, polarCenter)
|
||||
drawRadarView(canvas)
|
||||
drawRadarText(canvas)
|
||||
if (!pass.tle.isDeepspace) drawPassTrajectory(canvas, pass)
|
||||
drawSatellite(canvas, pass)
|
||||
if (!satPass.tle.isDeepspace) drawPassTrajectory(canvas, satPass)
|
||||
drawSatellite(canvas, satPass)
|
||||
}
|
||||
|
||||
|
||||
private fun drawRadarView(cvs: Canvas) {
|
||||
cvs.drawLine(-radius, 0f, radius, 0f, radarPaint)
|
||||
cvs.drawLine(0f, -radius, 0f, radius, radarPaint)
|
||||
+4
-4
@@ -2,22 +2,22 @@
|
||||
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
|
||||
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,
|
||||
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
|
||||
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.ui.adapters
|
||||
package com.rtbishop.look4sat.ui.polarScreen
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
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.content.pm.PackageManager
|
||||
+9
-9
@@ -2,22 +2,22 @@
|
||||
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
|
||||
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.
|
||||
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.
|
||||
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.ui.adapters
|
||||
package com.rtbishop.look4sat.ui.sourcesDialog
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
+5
-6
@@ -1,23 +1,23 @@
|
||||
/*******************************************************************************
|
||||
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.ui.mainScreen
|
||||
package com.rtbishop.look4sat.ui.sourcesDialog
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
@@ -28,10 +28,9 @@ import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
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.databinding.DialogSourcesBinding
|
||||
import com.rtbishop.look4sat.ui.adapters.SourcesAdapter
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
+1
-1
@@ -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.
|
||||
******************************************************************************/
|
||||
|
||||
package com.rtbishop.look4sat.ui.mainScreen
|
||||
package com.rtbishop.look4sat.ui.splashDialog
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
@@ -26,6 +26,7 @@ import com.github.amsacode.predict4java.GroundStationPosition
|
||||
import javax.inject.Inject
|
||||
|
||||
class PrefsManager @Inject constructor(val preferences: SharedPreferences) {
|
||||
|
||||
companion object {
|
||||
const val keyLatitude = "latitude"
|
||||
const val keyLongitude = "longitude"
|
||||
@@ -61,7 +62,6 @@ class PrefsManager @Inject constructor(val preferences: SharedPreferences) {
|
||||
putString(keyLatitude, latitude.toString())
|
||||
putString(keyLongitude, longitude.toString())
|
||||
putString(keyAltitude, altitude.toString())
|
||||
apply()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,6 @@ class PrefsManager @Inject constructor(val preferences: SharedPreferences) {
|
||||
}
|
||||
|
||||
fun setFirstLaunchDone() {
|
||||
preferences.edit {
|
||||
putBoolean(keyIsFirstLaunch, false)
|
||||
apply()
|
||||
}
|
||||
preferences.edit { putBoolean(keyIsFirstLaunch, false) }
|
||||
}
|
||||
}
|
||||
@@ -26,18 +26,19 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
class RecyclerDivider(private val resId: Int) : RecyclerView.ItemDecoration() {
|
||||
|
||||
override fun onDrawOver(c: Canvas, parent: RecyclerView) {
|
||||
val divider = ContextCompat.getDrawable(parent.context, resId)!!
|
||||
val left = parent.paddingLeft
|
||||
val right = parent.width - parent.paddingRight
|
||||
parent.adapter?.itemCount?.let { childCount ->
|
||||
for (i in 0 until childCount) {
|
||||
if (i == (childCount - 1)) continue
|
||||
parent.getChildAt(i)?.let {
|
||||
val params = it.layoutParams as RecyclerView.LayoutParams
|
||||
val top = it.bottom + params.bottomMargin
|
||||
val bottom = top + divider.intrinsicHeight
|
||||
divider.setBounds(left, top, right, bottom)
|
||||
divider.draw(c)
|
||||
ContextCompat.getDrawable(parent.context, resId)?.let { drawable ->
|
||||
val leftPos = parent.paddingLeft
|
||||
val rightPos = parent.width - parent.paddingRight
|
||||
parent.adapter?.itemCount?.let { childCount ->
|
||||
for (i in 0 until childCount) {
|
||||
if (i == (childCount - 1)) continue
|
||||
parent.getChildAt(i)?.let { view ->
|
||||
val params = view.layoutParams as RecyclerView.LayoutParams
|
||||
val topPos = view.bottom + params.bottomMargin
|
||||
val bottomPos = topPos + drawable.intrinsicHeight
|
||||
drawable.setBounds(leftPos, topPos, rightPos, bottomPos)
|
||||
drawable.draw(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import com.github.amsacode.predict4java.TLE
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
import com.squareup.moshi.Moshi
|
||||
|
||||
object TypeConverters {
|
||||
object RoomConverters {
|
||||
|
||||
private lateinit var tleAdapter: JsonAdapter<TLE>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.mainScreen.InfoFragment">
|
||||
tools:context=".ui.infoScreen.InfoFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<fragment
|
||||
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">
|
||||
<action
|
||||
android:id="@+id/action_entries_to_passes"
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<fragment
|
||||
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">
|
||||
<action
|
||||
android:id="@+id/action_passes_to_polar"
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
<fragment
|
||||
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">
|
||||
<action
|
||||
android:id="@+id/action_polar_to_passes"
|
||||
@@ -55,24 +55,24 @@
|
||||
|
||||
<fragment
|
||||
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" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_prefs"
|
||||
android:name="com.rtbishop.look4sat.ui.mainScreen.PrefsFragment" />
|
||||
android:name="com.rtbishop.look4sat.ui.prefsScreen.PrefsFragment" />
|
||||
|
||||
<fragment
|
||||
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" />
|
||||
<dialog
|
||||
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" />
|
||||
<dialog
|
||||
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" />
|
||||
|
||||
</navigation>
|
||||
Reference in new issue
Block a user