Satellite tracker and pass predictor for Android, inspired by Gpredict
Kotlin amsatcelestrakgpsham-radiohamlibhamradiokotlinnasaradiosatellitesatellite-datasatellite-positionsatellite-predictionsatellitessatnogssdrspacespacexstarlink
v2.2.1 - Hotfix for ClassCastException in SharedPrefs
Arty Bishop6c78d17faf3e
diff --git a/app/build.gradle b/app/build.gradleindex a6deccf4..539a9db5 100644--- a/app/build.gradle+++ b/app/build.gradle@@ -13,8 +13,8 @@ android {applicationId "com.rtbishop.look4sat"minSdkVersion 21targetSdkVersion 30- versionCode 220- versionName "2.2.0"+ versionCode 221+ versionName "2.2.1"}buildTypes {diff --git a/app/src/main/java/com/rtbishop/look4sat/repository/PrefsRepo.kt b/app/src/main/java/com/rtbishop/look4sat/repository/PrefsRepo.ktindex a033be21..f794b9de 100644--- a/app/src/main/java/com/rtbishop/look4sat/repository/PrefsRepo.kt+++ b/app/src/main/java/com/rtbishop/look4sat/repository/PrefsRepo.kt@@ -26,13 +26,13 @@ import com.squareup.moshi.Moshiimport com.squareup.moshi.Typesimport javax.inject.Inject-class PrefsRepo @Inject constructor(val preferences: SharedPreferences, val moshi: Moshi) {+class PrefsRepo @Inject constructor(val preferences: SharedPreferences, moshi: Moshi) {private val sourcesType = Types.newParameterizedType(List::class.java, TleSource::class.java)private val sourcesAdapter = moshi.adapter<List<TleSource>>(sourcesType)companion object {- const val keySources = "tleSources"+ const val keySources = "sourcesListJson"const val keyLatitude = "latitude"const val keyLongitude = "longitude"const val keyAltitude = "altitude"@@ -99,16 +99,16 @@ class PrefsRepo @Inject constructor(val preferences: SharedPreferences, val mosh}fun loadTleSources(): List<TleSource> {- preferences.getString(keySources, null)?.let { sourcesJson ->- sourcesAdapter.fromJson(sourcesJson)?.let { loadedSources ->- return if (loadedSources.isNotEmpty()) {- loadedSources- } else {- loadDefaultSources()- }+ return try {+ val sourcesString = preferences.getString(keySources, String())+ if (sourcesString.isNullOrEmpty()) {+ loadDefaultSources()+ } else {+ sourcesAdapter.fromJson(sourcesString) ?: loadDefaultSources()}+ } catch (exception: ClassCastException) {+ loadDefaultSources()}- return loadDefaultSources()}fun saveTleSources(sources: List<TleSource>) {diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/SharedViewModel.kt b/app/src/main/java/com/rtbishop/look4sat/ui/SharedViewModel.ktindex 987264f7..52a60a22 100644--- a/app/src/main/java/com/rtbishop/look4sat/ui/SharedViewModel.kt+++ b/app/src/main/java/com/rtbishop/look4sat/ui/SharedViewModel.kt@@ -56,7 +56,7 @@ class SharedViewModel @Inject constructor(}}- fun getSources() = liveData { emit(prefsRepo.loadTleSources()) }+ fun getSources() = prefsRepo.loadTleSources()fun getSatItems() = satelliteRepo.getSatItems().asLiveData()fun getPasses(): LiveData<Result<MutableList<SatPass>>> = _passesfun getTransmittersForSat(satId: Int) =diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/infoScreen/InfoFragment.kt b/app/src/main/java/com/rtbishop/look4sat/ui/infoScreen/InfoFragment.ktindex 5facf235..1ed42c3e 100644--- a/app/src/main/java/com/rtbishop/look4sat/ui/infoScreen/InfoFragment.kt+++ b/app/src/main/java/com/rtbishop/look4sat/ui/infoScreen/InfoFragment.kt@@ -45,7 +45,9 @@ class InfoFragment : Fragment(R.layout.fragment_info) {infoBmc.setOnClickListener {gotoUrl("https://www.buymeacoffee.com/rtbishop")}- infoThanks.movementMethod = LinkMovementMethod.getInstance()+ val moveMethod = LinkMovementMethod.getInstance()+ infoThanks.movementMethod = moveMethod+ infoWarranty.movementMethod = moveMethod}}diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/sourcesDialog/SourcesDialog.kt b/app/src/main/java/com/rtbishop/look4sat/ui/sourcesDialog/SourcesDialog.ktindex c9b0ed82..95630081 100644--- a/app/src/main/java/com/rtbishop/look4sat/ui/sourcesDialog/SourcesDialog.kt+++ b/app/src/main/java/com/rtbishop/look4sat/ui/sourcesDialog/SourcesDialog.kt@@ -41,27 +41,24 @@ class SourcesDialog : AppCompatDialogFragment() {override fun onViewCreated(view: View, state: Bundle?) {super.onViewCreated(view, state)- viewModel.getSources().observe(viewLifecycleOwner, { sources ->- val sourcesAdapter = SourcesAdapter()- sourcesAdapter.setSources(sources)- DialogSourcesBinding.bind(view).apply {- dialog?.window?.setLayout(- WindowManager.LayoutParams.MATCH_PARENT,- WindowManager.LayoutParams.WRAP_CONTENT- )- tleSourcesRecycler.apply {- adapter = sourcesAdapter- layoutManager = LinearLayoutManager(requireContext())- }- tleSourceBtnAdd.setOnClickListener {- sourcesAdapter.addSource()- }- tleSourcesBtnPos.setOnClickListener {- viewModel.updateEntriesFromSources(sourcesAdapter.getSources())- dismiss()- }- tleSourcesBtnNeg.setOnClickListener { dismiss() }+ val sourcesAdapter = SourcesAdapter().apply { setSources(viewModel.getSources()) }+ DialogSourcesBinding.bind(view).apply {+ dialog?.window?.setLayout(+ WindowManager.LayoutParams.MATCH_PARENT,+ WindowManager.LayoutParams.WRAP_CONTENT+ )+ tleSourcesRecycler.apply {+ adapter = sourcesAdapter+ layoutManager = LinearLayoutManager(requireContext())}- })+ tleSourceBtnAdd.setOnClickListener {+ sourcesAdapter.addSource()+ }+ tleSourcesBtnPos.setOnClickListener {+ viewModel.updateEntriesFromSources(sourcesAdapter.getSources())+ dismiss()+ }+ tleSourcesBtnNeg.setOnClickListener { dismiss() }+ }}}\ No newline at end of filediff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xmlindex 329ca35c..ed60406e 100644--- a/app/src/main/res/values-ru/strings.xml+++ b/app/src/main/res/values-ru/strings.xml@@ -77,6 +77,6 @@<a href="https://db.satnogs.org/">SatNOGS</a>, API и базу данных с огромным количеством информации о спутниках.\n— <a href="https://square.github.io/">Square</a> за библиотеки OkHttp, Retrofit, Moshi и доступк ним по лицензии <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></string>- <string name="info_warranty"><a href="https://sites.google.com/view/look4sat-privacy-policy/home">Политика конфиденциальности</a>.- Это ПО поставляется без гарантий. Подробности в лицензии <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPLv3</a>.</string>+ <string name="info_warranty"><a href="https://sites.google.com/view/look4sat-privacy-policy/home">Политика конфиденциальности</a>+ \nЭто ПО поставляется без гарантий. \nПодробности в лицензии <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPLv3</a>.</string></resources>diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 5fd82a30..4c6ac071 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -97,6 +97,6 @@\n— <a href="https://square.github.io/">Square</a> for epic OkHttp, Retrofit and Moshi libsavailable under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a> license.</string>- <string name="info_warranty"><a href="https://sites.google.com/view/look4sat-privacy-policy/home">Privacy Policy</a>.- This application comes with absolutely no warranty. See the <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPLv3</a> for details.</string>+ <string name="info_warranty"><a href="https://sites.google.com/view/look4sat-privacy-policy/home">Privacy Policy</a>+ \nThis app comes with no warranty. \nSee the <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPLv3</a> license for details.</string></resources>