mirror of
https://github.com/rt-bishop/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Minor refactoring. Changes to the app name and the package.
This commit is contained in:
1 parent
1b741bc572
commit
0b93780d7c
28 files changed
+115
-177
No files matched your search
@@ -1,22 +0,0 @@
|
||||
package com.rtbishop.lookingsat
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.rtbishop.lookingsat", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.rtbishop.lookingsat">
|
||||
package="com.rtbishop.look4sat">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:name=".LookingSatApp"
|
||||
android:name="com.rtbishop.look4sat.Look4SatApp"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
@@ -15,7 +15,7 @@
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity
|
||||
android:name=".ui.MainActivity"
|
||||
android:name="com.rtbishop.look4sat.ui.MainActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.Splash">
|
||||
|
||||
+4
-4
@@ -17,13 +17,13 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat
|
||||
package com.rtbishop.look4sat
|
||||
|
||||
import android.app.Application
|
||||
import com.rtbishop.lookingsat.di.AppComponent
|
||||
import com.rtbishop.lookingsat.di.DaggerAppComponent
|
||||
import com.rtbishop.look4sat.di.AppComponent
|
||||
import com.rtbishop.look4sat.di.DaggerAppComponent
|
||||
|
||||
class LookingSatApp : Application() {
|
||||
class Look4SatApp : Application() {
|
||||
|
||||
val appComponent: AppComponent by lazy {
|
||||
DaggerAppComponent.factory().create(applicationContext)
|
||||
+34
-33
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat
|
||||
package com.rtbishop.look4sat
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
@@ -25,6 +25,7 @@ import android.content.SharedPreferences
|
||||
import android.location.Location
|
||||
import androidx.core.content.edit
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.github.amsacode.predict4java.GroundStationPosition
|
||||
@@ -32,10 +33,9 @@ import com.github.amsacode.predict4java.PassPredictor
|
||||
import com.github.amsacode.predict4java.SatNotFoundException
|
||||
import com.github.amsacode.predict4java.TLE
|
||||
import com.google.android.gms.location.FusedLocationProviderClient
|
||||
import com.rtbishop.lookingsat.repo.Repository
|
||||
import com.rtbishop.lookingsat.repo.SatPass
|
||||
import com.rtbishop.lookingsat.repo.SatPassPrefs
|
||||
import com.rtbishop.lookingsat.repo.Transmitter
|
||||
import com.rtbishop.look4sat.repo.Repository
|
||||
import com.rtbishop.look4sat.repo.SatPass
|
||||
import com.rtbishop.look4sat.repo.Transmitter
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -70,42 +70,40 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
lateinit var repository: Repository
|
||||
|
||||
init {
|
||||
(app as LookingSatApp).appComponent.inject(this)
|
||||
(app as Look4SatApp).appComponent.inject(this)
|
||||
}
|
||||
|
||||
private var passPrefs = SatPassPrefs(
|
||||
preferences.getString(keyHours, defValueHours)!!.toInt(),
|
||||
preferences.getString(keyMinEl, defValueMinEl)!!.toDouble()
|
||||
)
|
||||
val debugMessage = MutableLiveData("")
|
||||
val gsp = MutableLiveData<GroundStationPosition>(
|
||||
|
||||
private val _debugMessage = MutableLiveData<String>()
|
||||
val debugMessage: LiveData<String> = _debugMessage
|
||||
|
||||
private val _gsp = MutableLiveData<GroundStationPosition>(
|
||||
GroundStationPosition(
|
||||
preferences.getString(keyLat, defValueLoc)!!.toDouble(),
|
||||
preferences.getString(keyLon, defValueLoc)!!.toDouble(),
|
||||
preferences.getString(keyAlt, defValueLoc)!!.toDouble()
|
||||
)
|
||||
)
|
||||
val gsp: LiveData<GroundStationPosition> = _gsp
|
||||
|
||||
var satPassList = emptyList<SatPass>()
|
||||
var tleMainList = loadTwoLineElementFile()
|
||||
var selectionList = loadSelectionList()
|
||||
val updateFreq
|
||||
val updateFreq: Long
|
||||
get() = preferences.getString(keyUpdateFreq, defValueUpdateFreq)!!.toLong()
|
||||
|
||||
fun updateGsp() {
|
||||
val lat = preferences.getString(keyLat, defValueLoc)!!.toDouble()
|
||||
val lon = preferences.getString(keyLon, defValueLoc)!!.toDouble()
|
||||
val alt = preferences.getString(keyAlt, defValueLoc)!!.toDouble()
|
||||
gsp.postValue(GroundStationPosition(lat, lon, alt))
|
||||
_gsp.postValue(GroundStationPosition(lat, lon, alt))
|
||||
}
|
||||
|
||||
fun updatePassPref() {
|
||||
passPrefs = SatPassPrefs(
|
||||
preferences.getString(keyHours, defValueHours)!!.toInt(),
|
||||
preferences.getString(keyMinEl, defValueMinEl)!!.toDouble()
|
||||
)
|
||||
}
|
||||
|
||||
fun updateLocation() {
|
||||
fun getCurrentLocation() {
|
||||
locationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
||||
val lat = location?.latitude ?: 0.0
|
||||
val lon = location?.longitude ?: 0.0
|
||||
@@ -117,8 +115,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
putString(keyAlt, alt.toString())
|
||||
apply()
|
||||
}
|
||||
gsp.postValue(GroundStationPosition(lat, lon, alt))
|
||||
debugMessage.postValue("Location was updated")
|
||||
_gsp.postValue(GroundStationPosition(lat, lon, alt))
|
||||
_debugMessage.postValue("Location was updated")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,9 +132,10 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
close()
|
||||
}
|
||||
tleMainList = tleList
|
||||
debugMessage.postValue("TLE file was updated")
|
||||
selectionList = mutableListOf()
|
||||
_debugMessage.postValue("TLE file was updated")
|
||||
} catch (exception: IOException) {
|
||||
debugMessage.postValue("Couldn't update TLE file")
|
||||
_debugMessage.postValue("Couldn't update TLE file")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,9 +144,9 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
repository.updateTransmittersDatabase()
|
||||
debugMessage.postValue("Transmitters were updated")
|
||||
_debugMessage.postValue("Transmitters were updated")
|
||||
} catch (exception: IOException) {
|
||||
debugMessage.postValue("Couldn't update transmitters")
|
||||
_debugMessage.postValue("Couldn't update transmitters")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,26 +161,28 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
close()
|
||||
}
|
||||
} catch (exception: IOException) {
|
||||
debugMessage.postValue(exception.toString())
|
||||
_debugMessage.postValue(exception.toString())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getPasses() {
|
||||
val hoursAhead = preferences.getString(keyHours, defValueHours)!!.toInt()
|
||||
val minEl = preferences.getString(keyMinEl, defValueMinEl)!!.toDouble()
|
||||
val passList = mutableListOf<SatPass>()
|
||||
withContext(Dispatchers.Default) {
|
||||
selectionList.forEach { indexOfSelection ->
|
||||
val tle = tleMainList[indexOfSelection]
|
||||
try {
|
||||
val predictor = PassPredictor(tle, gsp.value)
|
||||
val passes = predictor.getPasses(Date(), passPrefs.hoursAhead, true)
|
||||
val passes = predictor.getPasses(Date(), hoursAhead, true)
|
||||
passes.forEach { passList.add(SatPass(tle, predictor, it)) }
|
||||
} catch (exception: IllegalArgumentException) {
|
||||
debugMessage.postValue("There was a problem with ${tle.name}")
|
||||
_debugMessage.postValue("There was a problem with ${tle.name}")
|
||||
} catch (exception: SatNotFoundException) {
|
||||
debugMessage.postValue("${tle.name} shall not pass")
|
||||
_debugMessage.postValue("${tle.name} shall not pass")
|
||||
}
|
||||
}
|
||||
passList.retainAll { it.pass.maxEl >= passPrefs.maxEl }
|
||||
passList.retainAll { it.pass.maxEl >= minEl }
|
||||
passList.sortBy { it.pass.startTime }
|
||||
}
|
||||
satPassList = passList
|
||||
@@ -198,9 +199,9 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val tleList = ObjectInputStream(fileInputStream).readObject()
|
||||
return tleList as List<TLE>
|
||||
} catch (exception: FileNotFoundException) {
|
||||
debugMessage.postValue("TLE file wasn't found")
|
||||
_debugMessage.postValue("TLE file wasn't found")
|
||||
} catch (exception: IOException) {
|
||||
debugMessage.postValue(exception.toString())
|
||||
_debugMessage.postValue(exception.toString())
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
@@ -212,9 +213,9 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val selectionList = ObjectInputStream(fileInputStream).readObject()
|
||||
return selectionList as MutableList<Int>
|
||||
} catch (exception: FileNotFoundException) {
|
||||
debugMessage.postValue("Selection file wasn't found")
|
||||
_debugMessage.postValue("Selection file wasn't found")
|
||||
} catch (exception: IOException) {
|
||||
debugMessage.postValue(exception.toString())
|
||||
_debugMessage.postValue(exception.toString())
|
||||
}
|
||||
return mutableListOf()
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.di
|
||||
package com.rtbishop.look4sat.di
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
+2
-2
@@ -17,10 +17,10 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.di
|
||||
package com.rtbishop.look4sat.di
|
||||
|
||||
import android.content.Context
|
||||
import com.rtbishop.lookingsat.MainViewModel
|
||||
import com.rtbishop.look4sat.MainViewModel
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import javax.inject.Singleton
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.di
|
||||
package com.rtbishop.look4sat.di
|
||||
|
||||
import com.rtbishop.lookingsat.network.TransmittersApi
|
||||
import com.rtbishop.look4sat.network.TransmittersApi
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import okhttp3.OkHttpClient
|
||||
+3
-3
@@ -17,12 +17,12 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.di
|
||||
package com.rtbishop.look4sat.di
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import com.rtbishop.lookingsat.storage.TransmittersDao
|
||||
import com.rtbishop.lookingsat.storage.TransmittersDb
|
||||
import com.rtbishop.look4sat.storage.TransmittersDao
|
||||
import com.rtbishop.look4sat.storage.TransmittersDb
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import javax.inject.Singleton
|
||||
+5
-2
@@ -17,13 +17,16 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.network
|
||||
package com.rtbishop.look4sat.network
|
||||
|
||||
import com.rtbishop.lookingsat.repo.Transmitter
|
||||
import com.rtbishop.look4sat.repo.Transmitter
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.io.InputStream
|
||||
import java.io.SequenceInputStream
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class RemoteDataSource @Inject constructor(
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.network
|
||||
package com.rtbishop.look4sat.network
|
||||
|
||||
import com.rtbishop.lookingsat.repo.Transmitter
|
||||
import com.rtbishop.look4sat.repo.Transmitter
|
||||
import retrofit2.http.GET
|
||||
|
||||
interface TransmittersApi {
|
||||
+3
-3
@@ -17,10 +17,10 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.repo
|
||||
package com.rtbishop.look4sat.repo
|
||||
|
||||
import com.rtbishop.lookingsat.network.RemoteDataSource
|
||||
import com.rtbishop.lookingsat.storage.LocalDataSource
|
||||
import com.rtbishop.look4sat.network.RemoteDataSource
|
||||
import com.rtbishop.look4sat.storage.LocalDataSource
|
||||
import java.io.InputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.repo
|
||||
package com.rtbishop.look4sat.repo
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.github.amsacode.predict4java.PassPredictor
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.repo
|
||||
package com.rtbishop.look4sat.repo
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.storage
|
||||
package com.rtbishop.look4sat.storage
|
||||
|
||||
import com.rtbishop.lookingsat.repo.Transmitter
|
||||
import com.rtbishop.look4sat.repo.Transmitter
|
||||
import javax.inject.Inject
|
||||
|
||||
class LocalDataSource @Inject constructor(private val transmittersDao: TransmittersDao) {
|
||||
+2
-2
@@ -17,13 +17,13 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.storage
|
||||
package com.rtbishop.look4sat.storage
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.rtbishop.lookingsat.repo.Transmitter
|
||||
import com.rtbishop.look4sat.repo.Transmitter
|
||||
|
||||
@Dao
|
||||
interface TransmittersDao {
|
||||
+2
-2
@@ -17,11 +17,11 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.storage
|
||||
package com.rtbishop.look4sat.storage
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import com.rtbishop.lookingsat.repo.Transmitter
|
||||
import com.rtbishop.look4sat.repo.Transmitter
|
||||
|
||||
@Database(entities = [Transmitter::class], version = 1, exportSchema = false)
|
||||
abstract class TransmittersDb : RoomDatabase() {
|
||||
+2
-2
@@ -17,14 +17,14 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.ui
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.rtbishop.lookingsat.R
|
||||
import com.rtbishop.look4sat.R
|
||||
|
||||
class CreditsFragment : Fragment() {
|
||||
|
||||
+16
-18
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.ui
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Intent
|
||||
@@ -43,8 +43,8 @@ import androidx.navigation.ui.navigateUp
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
import com.rtbishop.lookingsat.MainViewModel
|
||||
import com.rtbishop.lookingsat.R
|
||||
import com.rtbishop.look4sat.MainViewModel
|
||||
import com.rtbishop.look4sat.R
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
@@ -69,24 +69,23 @@ class MainActivity : AppCompatActivity() {
|
||||
setTheme(R.style.AppTheme)
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
|
||||
setupComponents()
|
||||
setupObservers()
|
||||
setupDrawer()
|
||||
}
|
||||
|
||||
private fun setupComponents() {
|
||||
val navController = findNavController(R.id.nav_host)
|
||||
val navView: NavigationView = findViewById(R.id.nav_view)
|
||||
val header = navView.getHeaderView(0)
|
||||
val toolbar: Toolbar = findViewById(R.id.toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
|
||||
|
||||
timerLayout = findViewById(R.id.toolbar_layout_timer)
|
||||
drawerLayout = findViewById(R.id.drawer_layout)
|
||||
|
||||
drawerLat = header.findViewById(R.id.drawer_lat_value)
|
||||
drawerLon = header.findViewById(R.id.drawer_lon_value)
|
||||
|
||||
drawerBtnLoc = header.findViewById(R.id.drawer_btn_loc)
|
||||
drawerBtnTle = header.findViewById(R.id.drawer_btn_tle)
|
||||
drawerBtnTrans = header.findViewById(R.id.drawer_btn_trans)
|
||||
@@ -98,7 +97,6 @@ class MainActivity : AppCompatActivity() {
|
||||
drawerLayout
|
||||
)
|
||||
|
||||
val navController = findNavController(R.id.nav_host)
|
||||
setupActionBarWithNavController(navController, appBarConfig)
|
||||
navView.setupWithNavController(navController)
|
||||
|
||||
@@ -122,19 +120,19 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupDrawer() {
|
||||
private fun setupObservers() {
|
||||
viewModel.debugMessage.observe(this, Observer { debug_message ->
|
||||
if (debug_message != "") {
|
||||
Toast.makeText(this, debug_message, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.gsp.observe(this, Observer { gsp ->
|
||||
drawerLat.text = String.format("%.4f", gsp.latitude)
|
||||
drawerLon.text = String.format("%.4f", gsp.longitude)
|
||||
drawerLat.text = String.format(getString(R.string.pattern_lat), gsp.latitude)
|
||||
drawerLon.text = String.format(getString(R.string.pattern_lon), gsp.longitude)
|
||||
})
|
||||
}
|
||||
|
||||
drawerBtnLoc.setOnClickListener { updateLocation() }
|
||||
private fun setupDrawer() {
|
||||
drawerBtnLoc.setOnClickListener { requestLocationUpdate() }
|
||||
drawerBtnTle.setOnClickListener { viewModel.updateAndSaveTleFile() }
|
||||
drawerBtnTrans.setOnClickListener { viewModel.updateTransmittersDatabase() }
|
||||
drawerBtnGithub.setOnClickListener {
|
||||
@@ -143,15 +141,15 @@ class MainActivity : AppCompatActivity() {
|
||||
drawerBtnExit.setOnClickListener { finish() }
|
||||
}
|
||||
|
||||
private fun updateLocation() {
|
||||
private fun requestLocationUpdate() {
|
||||
if (ContextCompat.checkSelfPermission(this, permLocation) != permGranted) {
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(this, permLocation)) {
|
||||
Toast.makeText(this, "Missing permissions", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(this, getString(R.string.no_permissions), Toast.LENGTH_LONG).show()
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, arrayOf(permLocation), permLocationCode)
|
||||
}
|
||||
} else {
|
||||
viewModel.updateLocation()
|
||||
viewModel.getCurrentLocation()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +157,7 @@ class MainActivity : AppCompatActivity() {
|
||||
when (reqCode) {
|
||||
permLocationCode -> {
|
||||
if (res.isNotEmpty() && res[0] == permGranted) {
|
||||
viewModel.updateLocation()
|
||||
viewModel.getCurrentLocation()
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.ui
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
@@ -35,9 +35,9 @@ import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.amsacode.predict4java.SatPos
|
||||
import com.rtbishop.lookingsat.MainViewModel
|
||||
import com.rtbishop.lookingsat.R
|
||||
import com.rtbishop.lookingsat.repo.SatPass
|
||||
import com.rtbishop.look4sat.MainViewModel
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.repo.SatPass
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
+3
-3
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.ui
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -26,8 +26,8 @@ import android.widget.TextView
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.rtbishop.lookingsat.R
|
||||
import com.rtbishop.lookingsat.repo.SatPass
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.repo.SatPass
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
+4
-11
@@ -17,15 +17,15 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.ui
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.rtbishop.lookingsat.MainViewModel
|
||||
import com.rtbishop.lookingsat.R
|
||||
import com.rtbishop.look4sat.MainViewModel
|
||||
import com.rtbishop.look4sat.R
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
@@ -51,14 +51,7 @@ class SettingsFragment : PreferenceFragmentCompat(),
|
||||
if (key == context!!.getText(R.string.key_lat) ||
|
||||
key == context!!.getText(R.string.key_lon) ||
|
||||
key == context!!.getText(R.string.key_alt)
|
||||
) {
|
||||
viewModel.updateGsp()
|
||||
}
|
||||
if (key == context!!.getText(R.string.key_hours_ahead) ||
|
||||
key == context!!.getText(R.string.key_min_el)
|
||||
) {
|
||||
viewModel.updatePassPref()
|
||||
}
|
||||
) viewModel.updateGsp()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
+4
-4
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.ui
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
@@ -36,9 +36,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.amsacode.predict4java.TLE
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.rtbishop.lookingsat.MainViewModel
|
||||
import com.rtbishop.lookingsat.R
|
||||
import com.rtbishop.lookingsat.repo.SatPass
|
||||
import com.rtbishop.look4sat.MainViewModel
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.repo.SatPass
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.TimeUnit
|
||||
+3
-3
@@ -17,15 +17,15 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.ui
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.rtbishop.lookingsat.R
|
||||
import com.rtbishop.lookingsat.repo.Transmitter
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.repo.Transmitter
|
||||
|
||||
class TransAdapter : RecyclerView.Adapter<TransAdapter.TransHolder>() {
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.rtbishop.lookingsat.ui
|
||||
package com.rtbishop.look4sat.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.*
|
||||
@@ -35,8 +35,8 @@ import com.github.amsacode.predict4java.Position
|
||||
import com.github.amsacode.predict4java.SatPos
|
||||
import com.github.amsacode.predict4java.TLE
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.rtbishop.lookingsat.MainViewModel
|
||||
import com.rtbishop.lookingsat.R
|
||||
import com.rtbishop.look4sat.MainViewModel
|
||||
import com.rtbishop.look4sat.R
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* LookingSat. Amateur radio & weather satellite tracker and passes calculator.
|
||||
* Copyright (C) 2019 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.lookingsat.repo
|
||||
|
||||
data class SatPassPrefs(val hoursAhead: Int, val maxEl: Double)
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_sky"
|
||||
android:name="com.rtbishop.lookingsat.ui.SkyFragment"
|
||||
android:name="com.rtbishop.look4sat.ui.SkyFragment"
|
||||
android:label="@string/menu_sky"
|
||||
tools:layout="@layout/fragment_sky">
|
||||
<action
|
||||
@@ -21,31 +21,31 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_radar"
|
||||
android:name="com.rtbishop.lookingsat.ui.RadarFragment"
|
||||
android:name="com.rtbishop.look4sat.ui.RadarFragment"
|
||||
android:label="@string/menu_radar"
|
||||
tools:layout="@layout/fragment_radar" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_map"
|
||||
android:name="com.rtbishop.lookingsat.ui.WorldMapFragment"
|
||||
android:name="com.rtbishop.look4sat.ui.WorldMapFragment"
|
||||
android:label="@string/menu_map"
|
||||
tools:layout="@layout/fragment_worldmap" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_credits"
|
||||
android:name="com.rtbishop.lookingsat.ui.CreditsFragment"
|
||||
android:name="com.rtbishop.look4sat.ui.CreditsFragment"
|
||||
android:label="@string/menu_credits"
|
||||
tools:layout="@layout/fragment_credits" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_about"
|
||||
android:name="com.rtbishop.lookingsat.ui.CreditsFragment"
|
||||
android:name="com.rtbishop.look4sat.ui.CreditsFragment"
|
||||
android:label="@string/menu_credits"
|
||||
tools:layout="@layout/fragment_credits" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_settings"
|
||||
android:name="com.rtbishop.lookingsat.ui.SettingsFragment"
|
||||
android:name="com.rtbishop.look4sat.ui.SettingsFragment"
|
||||
android:label="@string/menu_settings" />
|
||||
|
||||
</navigation>
|
||||
@@ -71,6 +71,7 @@
|
||||
<string name="no_mode">Mode: Null</string>
|
||||
<string name="no_uplink">Uplink: Null</string>
|
||||
<string name="no_downlink">Downlink: Null</string>
|
||||
<string name="no_permissions">Missing permissions</string>
|
||||
<string name="no_trans">No transmitters found for this Satellite</string>
|
||||
<string name="no_selected_sat">No satellites were shortlisted</string>
|
||||
|
||||
@@ -81,6 +82,8 @@
|
||||
<string name="trans_inverted">Inverted: Yes</string>
|
||||
<string name="trans_header">Transmitters:</string>
|
||||
|
||||
<string name="pattern_lat">%.4f</string>
|
||||
<string name="pattern_lon">%.4f</string>
|
||||
<string name="pattern_aos">AOS -%02d:%02d:%02d</string>
|
||||
<string name="pattern_trans_mode">Mode: %s</string>
|
||||
<string name="pattern_trans_inverted">Inverted: %s</string>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.rtbishop.lookingsat
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user